lundi 23 mars 2015

emberjs - update belongsTo from dropdown

I have a belongsTo relation between to models like so:



// models/event-type.js
import DS from 'ember-data';

export default DS.Model.extend({
title: DS.attr('string'),
category: DS.belongsTo('category', {async: true}),
events: DS.hasMany('event', {async: true})
});

// models/category.js
import DS from 'ember-data';

export default DS.Model.extend({
title: DS.attr('string'),
event_types: DS.hasMany('eventType')
});


In the event-type template I populate a dropdown with all available categories like so:



{{view "select"
content=categories
optionValuePath="content.id"
optionLabelPath="content.title"
selection=category.content
class="form-control"}}


Now, when I select another categorie and save the event-type model the updated category id is not submitted to the backend server... It's driving me nuts because I can't find whats the cause of this problem... or do I miss something (e.g. assign the new selected category model to the event-type, if so, how?) ?





Aucun commentaire:

Enregistrer un commentaire