diff --git a/app/assets/javascripts/discourse/views/topic_view.js b/app/assets/javascripts/discourse/views/topic_view.js index eb2d4d720..7f9d5f39b 100644 --- a/app/assets/javascripts/discourse/views/topic_view.js +++ b/app/assets/javascripts/discourse/views/topic_view.js @@ -71,12 +71,12 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, { } }.observes('controller.enteredAt'), - didInsertElement: function() { + _inserted: function() { this.bindScrolling({name: 'topic-view'}); - var topicView = this; + var self = this; $(window).resize('resize.discourse-on-scroll', function() { - topicView.scrolled(); + self.scrolled(); }); // This get seems counter intuitive, but it's to trigger the observer on @@ -88,10 +88,10 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, { if ($(e.target).hasClass('mention')) { return false; } return Discourse.ClickTrack.trackClick(e); }); - }, + }.on('didInsertElement'), // This view is being removed. Shut down operations - willDestroyElement: function() { + _destroyed: function() { this.unbindScrolling('topic-view'); $(window).unbind('resize.discourse-on-scroll'); @@ -102,7 +102,7 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, { // this happens after route exit, stuff could have trickled in this.set('controller.controllers.header.showExtraInfo', false); - }, + }.on('willDestroyElement'), debounceLoadSuggested: Discourse.debounce(function(){ if (this.get('isDestroyed') || this.get('isDestroying')) { return; } diff --git a/vendor/assets/javascripts/ember-cloaking.js b/vendor/assets/javascripts/ember-cloaking.js index 64eebdba0..cde63b596 100644 --- a/vendor/assets/javascripts/ember-cloaking.js +++ b/vendor/assets/javascripts/ember-cloaking.js @@ -95,6 +95,8 @@ @method scrolled **/ scrolled: function() { + if (!this.get('scrollingEnabled')) { return; } + var childViews = this.get('childViews'); if ((!childViews) || (childViews.length === 0)) { return; } @@ -189,11 +191,18 @@ $(window).bind('scroll.ember-cloak', onScrollMethod); this.addObserver('wrapperTop', self, onScrollMethod); this.addObserver('wrapperHeight', self, onScrollMethod); + + this.set('scrollingEnabled', true); }.on('didInsertElement'), - _endEvents: function() { + cleanUp: function() { $(document).unbind('touchmove.ember-cloak'); $(window).unbind('scroll.ember-cloak'); + this.set('scrollingEnabled', false); + }, + + _endEvents: function() { + this.cleanUp(); }.on('willDestroyElement') });