ember.js - Finding a few records by id using ember-data -
i trying load few favorite repositories travis-ci mobile trying put here
what have array of repository ids this:
var favoriterepos = ["668498","557554","7934","207993"];
how go loading these repos ember-data revision 12, the travis custom restadapter , travis api?
this have tried unsuccessfully far:
// in repo model - https://github.com/floydpink/travis-ci-www/blob/master/js/app/models/repo.js repo.reopenclass({ favorites : function (favorites) { // favorites array of repo-ids ["451069","538603"] var faves = ember.arrayproxy.create({ isloadedbinding : 'content.isloaded', content : ember.a([]) }); favorites.foreach(function (favorite) { faves.pushobject(repo.find(favorite)); }); return faves; } }); // , in favoritescontroller this.set('content', repo.favorites(favoriterepos));
so generic question is, how go loading few different records id, using ember-data?
you should able do:
repo.reopenclass({ favorites : function (favorites) { // favorites array of repo-ids ["451069","538603"] return ember.arrayproxy.createwithmixins({ content: favorites.map(function(id) { return repo.find(id); }), isloaded: function() { return this.everyproperty('isloaded'); }.property('@each.isloaded'); }); } });
Comments
Post a Comment