mardi 14 avril 2015

Using ember-data to populate a table

I'm relatively new to Ember JS and have just begun to use ember-data to retrieve JSON data from my Laravel Eloquent-powered RESTful API.


I would like to populate a DataTables table with the data returned from the API and I have retrieved it as follows:



var unprocessedModels = this.store.find('myModel', {related: 'all'});


How do I go about converting this Ember DS.RecordArray in to a JSON object to pass in to my DateTables "data" option?


I have tried the RecordArray's .toArray() method but I don't get "clean" data & all of the RecordArray's methods/properties are present. I can see the data pulled from the server inside the RecordArray object when I use developer tools to examine it but I just can't seem to get at it.


I also considered just pulling in the data via an ajax call and using the resulting raw JSON, but I would not then be using Ember Data, which I would really like to do if it makes sense to do so in this example.


Can anyone can guide me on the best approach please?


Thanks.





Aucun commentaire:

Enregistrer un commentaire