Just getting started with Ember.js, so after a workign myself through the various tutorials online for a couple of weeks(…), I really can't puzzle out the following question.
I want to display 4 models on 1 route. How can I do that, while avoiding making 4 server calls?
More inforamtion:
I want to display records of type "person", "quote", "product" and "case" on my index page.
In my index route, (routes/index.js) I can load them using:
import Ember from "ember";
export default Ember.Route.extend({
model(){
return Ember.RSVP.hash({
persons : this.get('store').findAll('person'),
quotes : this.get('store').findAll('quote'),
cases : this.get('store').findAll('case'),
products: this.get('store').findAll('product')
});
}
});
(And in my adapter, adapters/application.js, I have: )
import DS from "ember-data";
export default DS.JSONAPIAdapter.extend({
host : 'http://localhost:8080/dummy.php',
pathForType: function (type) {
return "?type=" + type;
}
});
This works very nicely(, but ember.js makes get 4 requests:
However, I could easily provide a JSON file that provides records of all 4 types.
So, how can I tell ember.js:
"Here's a nice large JSON file, full of records. Now, use only records of the 'person'-type for the person model, and idem dito for 'case', 'quote' and 'product'
?
Aucun commentaire:
Enregistrer un commentaire