I have two models related to one another via belongsTo (a reciprocal relationship, i.e. 1:1) utilizing the async property. Having retrieved one record and setting it to the Model on the router, I have access to the properties in the main record and its associate—everything works fine there. I've used input helpers to bind properties to input and textarea elements so that users can make changes to the model, including properties on the associated record. However when I run my save() on my model, nothing happens. Using the Ember Chrome Extension, I see that the model isn't updated by the changes made in the input (at least not immediately) and doesn't ever register as dirty in the data explorer. Yet, echoing the same property to the page shows that the input is bound to the property. What am I missing? I can't seem to find any documentation about how to call save() on associated models or any other solution to this.
Entry.js (Model)
export default DS.Model.extend({
// Properties
entry: DS.attr('Number'),
...
// Relational properties
definition: DS.belongsTo('definition', {async: true}),
...
});
Definition.js (Model)
export default DS.Model.extend({
// Properties
blocks: DS.attr(),
...
// Relational properties
entry: DS.belongsTo('entry', {async: true}),
...
});
Route.js
export default Ember.Route.extend({
model: function(params){
return this.store.find('Entry', params.entry_id);
},
actions: {
saveDef: function(){
// console.log('Saving . . .');
var entry = this.controller.get('content');
entry.save().then(function(){
// console.log('Saved Success');
}, function(err){
// console.log(err);
});
}
}
});
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire