Ember Component does not reload on route reload or transitionTo

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Ember Component does not reload on route reload or transitionTo



I have an ember route that calls an ember component to display all the data.



I have a case in which the route's key changes and I reload using route.transitionTo. The data is loaded fine. But the problem is the component does stuff in the init and didInsertElement methods, which on the route.transitionTo aren't triggered.


route.transitionTo


init


didInsertElement


route.transitionTo



How can I make sure on transitionTo the component is called again?


transitionTo



I can't use route.refresh because that doesn't do the model hook.


route.refresh



Any help will be appreciated, Thank you!




1 Answer
1



Well, there is a harder and better way, and there is a lazy and fast way:



E.g.:
router.hbs


component-name parameter=parameter



Component.js


lineWidth: Ember.computed('parameter', function()
// I will run here if I get the parameter (and the parameter changed in route)
),



router.hbs


#if reload
component-name
/if



router.js


this.set('reload', false);
Ember.run.next(() =>
this.set('reload', true);
);





I already went with the first option, it works. But it just doesn't feel right that I have to put a listener for it, was hoping for a cleaner option. Second is too much. But thank you for taking the time out!
– nullpointer
Aug 10 at 21:30






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS