in Ember.js I have route with model. Could you help me, when I'm on route playlist how to reload this route (or set new data to model) called by callback from another JS function? I've been looking to documentation so long, but no help for me.
App.PlaylistRoute = Ember.Route.extend({ setupController: function(controller, model) { $.getJSON('api/playlist.php?' + Math.random().toString(36), function (data) { controller.set('model', data); }); } });
Thanks a lot!
From your component, you need to call refreshCurrentRoute action. either you can use ember-route-action-helper or by passing the closure action.
An Ember route is built with three parts: An entry in the Ember router ( /app/router. js ), which maps between our route name and a specific URI. A route handler file, which sets up what should happen when that route is loaded (app/routes/about.
It seems the solution in the answer won't work for current route. I had a same issue and tried the solution here and it worked.
http://discuss.emberjs.com/t/refresh-current-view-page-after-language-change/4291/5#post_5
In your route.
actions: { sessionChanged: function() { this.refresh(); } }
and in your controller.
observeSession: function() { this.send("sessionChanged"); }.observes("session.isAuthenticated"),
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