Daniel V
Daniel V

Reputation: 43

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.

Upvotes: 3

Views: 1593

Answers (1)

Keo
Keo

Reputation: 1153

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
  }
},

Upvotes: 3

Related Questions