From e99789f504544fac93a8e057c5e88f3839203fed Mon Sep 17 00:00:00 2001 From: Daryl Koopersmith Date: Wed, 21 Nov 2012 20:34:46 +0000 Subject: [PATCH] Media: Refresh the window-wide uploader whenever a state is activated. Properly unbind controller events. fixes #22504, see #21390. git-svn-id: https://develop.svn.wordpress.org/trunk@22791 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/js/media-views.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wp-includes/js/media-views.js b/wp-includes/js/media-views.js index 3148926232..1cf25bee25 100644 --- a/wp-includes/js/media-views.js +++ b/wp-includes/js/media-views.js @@ -937,6 +937,10 @@ if ( this.collection && this.collection.off ) 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. if ( this.views ) this.views.dispose(); @@ -1044,6 +1048,7 @@ // Initialize window-wide uploader. if ( this.options.uploader ) { this.uploader = new media.view.UploaderWindow({ + controller: this, uploader: { dropzone: this.modal ? this.modal.$el : this.$el, container: this.$el @@ -1732,6 +1737,8 @@ // Ensure the dropzone is a jQuery collection. if ( uploader.dropzone && ! (uploader.dropzone instanceof $) ) uploader.dropzone = $( uploader.dropzone ); + + this.controller.on( 'activate', this.refresh, this ); }, refresh: function() {