Backbone: Scroll event not firing after back button is pressed
I'm using the following function to change the primary view of my Backbone
application:
changeView: function(view, options) {
if (this.contentView) {
this.contentView.undelegateEvents();
this.contentView.stopListening();
this.contentView = null;
}
this.contentView = view;
if (!options || (options && !options.noScroll)) {
$(document).scrollTop(0);
}
this.contentView.render();
},
As you can see, I'm resetting the scroll position every time the primary
view changes (so that the user doesn't land on the middle of a view after
scrolling down on the previous view). However, when the user presses the
back button, the scroll event isn't firing at all if you try to scroll
down. If you try to scroll up, however, then the scroll positions seems to
get reset to a position further down the page, after which scrolling works
normally.
Any ideas on what the cause might be?
No comments:
Post a Comment