but this won’t work for ember since there is not full page refresh. Would be great if there was a hook that would run on route change and also wait until the dom is fully ready.
App = Ember.Application.create({
ready: function() {
// will be called when the app is ready
}
})
There are several hooks that you can use on route change
App.IndexRoute = Ember.Route.extend(
activate: function() {
// executes when router enters route for the first time
}
);
But thats probably not what you want. You might want didInsertElement which is available on views. It would be executed when the corresponding template is rendered.
Do you want to focus everytime that the form is rendered?
That sounds like its getting very specific to your setup. You have to fire an event after transitioning to another object and add your jQuery code there. Does that make sense?
didInsertElement will not fire every time, when only the route context has changed.
Instead schedule your event in the afterRender queue, which will make sure that the event is fired every time the view is rerendered.
Related reads :