Media: Refresh the window-wide uploader whenever a state is activated. Properly unbind controller events. fixes #22504, see #21390.

git-svn-id: http://core.svn.wordpress.org/trunk@22791 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Daryl Koopersmith 2012-11-21 20:34:46 +00:00
parent 1923278143
commit 452c486d5f
1 changed files with 7 additions and 0 deletions

View File

@ -937,6 +937,10 @@
if ( this.collection && this.collection.off ) if ( this.collection && this.collection.off )
this.collection.off( null, null, this ); this.collection.off( null, null, this );
// Unbind controller events.
if ( this.controller && this.controller.off )
this.controller.off( null, null, this );
// Recursively dispose child views. // Recursively dispose child views.
if ( this.views ) if ( this.views )
this.views.dispose(); this.views.dispose();
@ -1044,6 +1048,7 @@
// Initialize window-wide uploader. // Initialize window-wide uploader.
if ( this.options.uploader ) { if ( this.options.uploader ) {
this.uploader = new media.view.UploaderWindow({ this.uploader = new media.view.UploaderWindow({
controller: this,
uploader: { uploader: {
dropzone: this.modal ? this.modal.$el : this.$el, dropzone: this.modal ? this.modal.$el : this.$el,
container: this.$el container: this.$el
@ -1732,6 +1737,8 @@
// Ensure the dropzone is a jQuery collection. // Ensure the dropzone is a jQuery collection.
if ( uploader.dropzone && ! (uploader.dropzone instanceof $) ) if ( uploader.dropzone && ! (uploader.dropzone instanceof $) )
uploader.dropzone = $( uploader.dropzone ); uploader.dropzone = $( uploader.dropzone );
this.controller.on( 'activate', this.refresh, this );
}, },
refresh: function() { refresh: function() {