Merge pull request #5795 from kevinansfield/fix-console-error

Fix teardown of resize handler in content management screen
This commit is contained in:
Hannah Wolfe 2015-09-02 22:17:51 +01:00
commit 9d1d4ae5ba

View File

@ -8,6 +8,8 @@ export default Ember.Component.extend({
resizeService: Ember.inject.service(),
_resizeListener: null,
calculatePreviewIsHidden: function () {
if (this.$('.content-preview').length) {
this.set('previewIsHidden', !this.$('.content-preview').is(':visible'));
@ -16,8 +18,12 @@ export default Ember.Component.extend({
didInsertElement: function () {
this._super(...arguments);
this._resizeListener = Ember.run.bind(this, this.calculatePreviewIsHidden);
this.get('resizeService').on('debouncedDidResize', this._resizeListener);
this.calculatePreviewIsHidden();
this.get('resizeService').on('debouncedDidResize',
Ember.run.bind(this, this.calculatePreviewIsHidden));
},
willDestroy: function () {
this.get('resizeService').off('debouncedDidResize', this._resizeListener);
}
});