From c4cfd5a7fe41f2eb66b7e5b6a7ea15c38d8d3657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Thu, 6 Feb 2014 12:54:06 +0100 Subject: [PATCH] BUGFIX: unbind the file uploader when closing the composer --- .../discourse/views/composer/composer_view.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/discourse/views/composer/composer_view.js b/app/assets/javascripts/discourse/views/composer/composer_view.js index 650e5047b0..47c5c5f566 100644 --- a/app/assets/javascripts/discourse/views/composer/composer_view.js +++ b/app/assets/javascripts/discourse/views/composer/composer_view.js @@ -258,13 +258,9 @@ Discourse.ComposerView = Discourse.View.extend(Ember.Evented, { } }); - // In case it's still bound somehow - $uploadTarget.fileupload('destroy'); - $uploadTarget.off(); - $uploadTarget.fileupload({ - url: Discourse.getURL('/uploads'), - dataType: 'json' + url: Discourse.getURL('/uploads'), + dataType: 'json' }); // submit - this event is triggered for each upload @@ -359,6 +355,12 @@ Discourse.ComposerView = Discourse.View.extend(Ember.Evented, { return this.initEditor(); }, + childWillDestroyElement: function() { + var $uploadTarget = $('#reply-control'); + $uploadTarget.fileupload('destroy'); + $uploadTarget.off(); + }, + toggleAdminOptions: function() { var $adminOpts = $('.admin-options-form'), $wmd = $('.wmd-controls'), @@ -419,6 +421,10 @@ Discourse.NotifyingTextArea = Ember.TextArea.extend({ didInsertElement: function() { return this.get('parent').childDidInsertElement(this); + }, + + willDestroyElement: function() { + return this.get('parent').childWillDestroyElement(this); } });