diff --git a/src/js/media/models/attachments.js b/src/js/media/models/attachments.js index 23510bd949f4c..f6185669dce86 100644 --- a/src/js/media/models/attachments.js +++ b/src/js/media/models/attachments.js @@ -212,8 +212,6 @@ var Attachments = Backbone.Collection.extend(/** @lends wp.media.model.Attachmen this.observers.push( attachments ); attachments.on( 'add change remove', this._validateHandler, this ); - attachments.on( 'add', this._addToTotalAttachments, this ); - attachments.on( 'remove', this._removeFromTotalAttachments, this ); attachments.on( 'reset', this._validateAllHandler, this ); this.validateAll( attachments ); return this; @@ -310,6 +308,11 @@ var Attachments = Backbone.Collection.extend(/** @lends wp.media.model.Attachmen this.reset( [], { silent: true } ); this.observe( attachments ); + // Bind total attachment count tracking only to the mirrored query + // collection, not to additional observed collections (e.g. selection). + attachments.on( 'add', this._addToTotalAttachments, this ); + attachments.on( 'remove', this._removeFromTotalAttachments, this ); + // Used for the search results. this.trigger( 'attachments:received', this ); return this;