Search code examples
ember.jsember-dataember-cli

how to reload hasMany relationship data in ember data 2.8


when first time calling model.get('list') its fetching record from server but second time its fetching from store but i want always response from server.

I am using

Ember js 2.8.3

Ember data 2.8.1

view model

import DS from 'ember-data';

export default DS.Model.extend({
   list:DS.hasMany('list',{async:true, readOnly: true}), //No I18N
});

route model function is like below

model:function()
{   
    var model = this.modelFor('view').get('list');
    if(model.get('content.isLoaded'))
    {
        return model.reload();
    }
    return model;
}

same model was making server request always in ember data 1.13.8

Thanks in advance for help.


Solution

  • I got the fix of problem .

    Instead of model.get('list'), need to use model.hasMany('list').

    model:function()
    {   
        var model = this.modelFor('view').hasMany('list');
        return model.reload();
    }