The emberjs docs say the following.
Note: A route with a dynamic segment will only have its model hook called when it is entered via the URL. If the route is entered through a transition (e.g. when using the link-to Handlebars helper), then a model context is already provided and the hook is not executed. Routes without dynamic segments will always execute the model hook.
How do I get the dynamic segment routes setupController code to execute every time. This seems to be an on going issue; see here.
The first time my code works. I press a button and everything executes as expected. But if I press the back button then press my application's button, there is information missing. Then if I refresh the page, everything is working again.
I populated an array to be displayed along side my model info. But when I navigate to that page via link, or press the back button, the array of information seems to be empty. I added some console.logs
and it looks my code is getting executed but when it comes to the template displaying the contents of the array, it is empty.
The solutions that have been raised talk about afterModel functions however, the logic that I need to execute (more then the first time it is loaded) is in a setupController function. Other solutions I saw involve complex helpers that seem to be over kill for just executing code every time a user hits a specific route.
So basically, how do you force dynamic segment routes to act like it was entered through the url bar?
Any help would be greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire