Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reload current route in Ember.js?

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!

like image 931
honzahommer Avatar asked Jan 31 '14 13:01

honzahommer


People also ask

How do I refresh a component in Ember?

From your component, you need to call refreshCurrentRoute action. either you can use ember-route-action-helper or by passing the closure action.

What is route in Ember JS?

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.


1 Answers

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"), 
like image 108
Atsuhiro Teshima Avatar answered Sep 17 '22 13:09

Atsuhiro Teshima