This is driving me bonkers.
How does Ember data want you to do server-side pagination? I find that using return this.store.query('jobs') in the route model() does not update templates when you createNewRecord.
My route:
export default Ember.Route.extend({
queryParams:{
page: { refreshModel: true }
},
model(params){
return this.store.findAll('casting',params); // No params ever reach server
}
});
My Controller:
export default Ember.Controller.extend({
queryParams: ['page'],
page:2});
I have a child route called create-a-job of the jobs route which shows a form:
export default Ember.Route.extend({
model()
return this.modelFor('jobs');
}
});
and the create-a-job route template create-a-job.hbs displays a component:
The component template (the one that is not updating) is as follows:
In jobs.hbs:
<li>
Id:
Reference:
Caption:
</li>
and the code in that component on submit (in tas-create-casting.js):
var data = {
type:'casting',
// attributes:{
created: "",
caption: this.get('model.caption'),
reference_caption: this.get('model.reference_caption'),
// }
};
// Create new record.
var record = this.get('store').createRecord('casting', data);
record.save();
On submit of a button, I add a job in the component of the child route tas-create-casting.js.
On save, if I have findAll in the route of jobs, the component updates and you can see the item added in real-time. But with this.store.query in the jobs route, you can't... but it is visible in Ember inspector and on reload of page it appears. But with this.store.query() I can send params for server-side filtering but with findAll it seems like I can't as it expects ALL items (which is plain impractical and non-scalable).
Stuck between a rock and a hard place, can anyone help here??
My question is if I use this.store.query in the jobs route how do I update the template after adding a new record with createNewRecord?
Or... if I do use findAll, which actually does update the template, how do I send params so that the server can filter via page or whatever?
Aucun commentaire:
Enregistrer un commentaire