Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember JS - Updating / Refreshing Model data From Route Action

This seems to be very simple problem but I can't find any solution for this. I want to refresh the data for unprocessedDailyDataFile from action. I can get the model by modelFor() method. But when I try to use get() and set() method with the model they fails as undefined.

Code for Route

App.AdminRoute = Ember.Route.extend({
    model: function(){
        return {
            companies: this.store.find('company'),
            unprocessedDailyDataFiles: this.store.find('unprocessedDailyDataFile')
        };
    },
    actions: {
        reloadUnprocessedDailyDataFile: function(){
            var model = this.modelFor('admin');
            // both properties from the model is accessible here
            // model.get() fails
            // model.set() fails
        }
    }
});
like image 465
Sisir Avatar asked Jan 19 '15 12:01

Sisir


1 Answers

For the model to reload, you can use

actions: {
           reloadUnprocessedDailyDataFile: function(){

               let  model =  this.get('controller.model'); // for Get and Set
               model.get('name'); 
               model.set({ name: 'john'});
    }
}
like image 103
siva - abc Avatar answered Oct 23 '22 02:10

siva - abc