Meph-
Meph-

Reputation: 677

Using ember-data RecordArray

I need inser data from model to dataTables "aaData:". I can't get objects from store at normal array, but as DS.RecordArray and what next? Console command to get some properties of some object is following command :

var dev = App.Model.Store.find("model")
dev.content.content[1]._data.someProperty

I don't know how to get this object or his property at javascript. Please, help :)

Upvotes: 0

Views: 2309

Answers (1)

Jeremy Green
Jeremy Green

Reputation: 8574

With Ember Data beta 1 or later you'd do this in a controller or route.

var dev = this.store.find("model");
// dev is a promise that will be resolved when/if
// the collection is actually loaded
dev.then(function(realDev){
    // at this point realDev is a DS.RecordArray
    // you could turn it into a real array by cally .toArray()
    var devAry = realDev.toArray();
    // then you can call get() on an item to retrieve a property
    var someProp = devAry[1].get('someProperty');
});

Upvotes: 4

Related Questions