I have a route /search that has a component (search bar) which calls an action on the route to refresh the model. The component is used on the index route as well as the search route, something like this:
home> search bar search> search bar
The search bar component calls an action that calls the following on index:
actions: {
goSearch: function(val) {
this.transitionTo('search', {queryParams: {keyword: val}});
}
}
On the search route, I have to add:
this.refresh();
in order to get the model to reload. Without it, it only changes the URL.
This works great but hitting back on the browser does not reload the model.
How should I go about this? I'm pretty sure I'm going about something wrong here.
You are not suposed to call refresh yourself. Instead add flag to query param that you want to make full reload.
queryParams: {
keyword: {
refreshModel: true
}
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With