Reputation: 532
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.
How can I make sure on transitionTo
the component is called again?
I can't use route.refresh
because that doesn't do the model hook.
Any help will be appreciated, Thank you!
Upvotes: 1
Views: 587
Reputation: 1657
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);
});
Upvotes: 1