Bharat Bhushan
Bharat Bhushan

Reputation: 2097

How can I refresh a specific route model data from application controller in Ember js?

I'm working with Emberjs. I want to refresh data of User route on change a select box value from application controller. On change value of select box just changing the params value not the roue. Ember does not refresh the model data based on new params.

onOrganizationChange:function(){
    var url="/users?org=" + this.selectedOrg;
    this.transitionToRoute(url);
}.observes('selectedOrg')

this function is called every time when user change the company from select box in application handelbar.

And my route map is

App.Router.map(function(){
this.resource("users", function(){
    this.resource("user", {path:"/:user_id"});
    this.route("add", {path:"/add"});
});});

Upvotes: 0

Views: 2499

Answers (1)

Susai
Susai

Reputation: 565

There is an option to refresh model in Route#queryParams. For example,

queryParams: {
  org: {
    refreshModel: true
  }
},

jsbin that illustrates the problem (without refreshModel) : http://jsbin.com/pinoco/1

Have a look into OPTING INTO A FULL TRANSITION section of http://emberjs.com/guides/routing/query-params/

Working bin : http://jsbin.com/norih/1

Upvotes: 4

Related Questions