Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember refreshing model from current route

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.

like image 787
Daniel V Avatar asked Dec 08 '25 16:12

Daniel V


1 Answers

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
  }
},
like image 103
Keo Avatar answered Dec 10 '25 06:12

Keo