Sisir
Sisir

Reputation: 2804

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
        }
    }
});

Upvotes: 6

Views: 3200

Answers (1)

siva - abc
siva - abc

Reputation: 181

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'});
    }
}

Upvotes: 1

Related Questions