Resetting scrool router


#1

Hi when i change the page there is many case that my page is not at the top so I see on the ember guide

https://guides.emberjs.com/v1.10.0/cookbook/user_interface_and_interaction/resetting_scroll_on_route_changes/

but where i put the code

App.ResetScroll = Ember.Mixin.create({
  activate: function() {
    this._super();
    window.scrollTo(0,0);
  }
});

in my ember application?


#2

Yeah, that can be a tricky thing. Perhaps look at the ember-router-scroll addon.


#3

It seems like you’re not in cli yet, and you’re also using ember 1.10… there must be a reason for that, which doesn’t matter right now…

The mixin you have should be enough already tho.

Just make sure you pass it to your routes:

App.SomeRoute = Ember.Route.extend(App.ResetScroll, {

 // your route implementation here

});