I have a challenge I cannot get around:
- I can't populate the selectlist with another model then article
- I have on template 'article' and use the same article view for creating new articles is that possible with the same select?
I hope someone has experience with it?
I have the following template:
<script type="text/x-handlebars" data-template-name="article">
Name: {{name}}
Landcodes: {{view Ember.Select contentBinding="model.landcode"
optionLabelPath="content.code optionValuePath="content.id"}}
</script>
Model
App.Article = DS.Model.extend({
naam: DS.attr('string'),
landcode: DS.hasMany('landcode')
});
App.Landcode = DS.Model.extend({
code: DS.attr('string'),
image: DS.attr('string')
});
Router
// for editing an existing article
App.ArticleRoute = Ember.Route.extend({
model: function (params) {
return this.store.find('article', params.id);
}
});
// for creating a new article
App.ArticleNewRoute = Ember.Route.extend({
renderTemplate: function () { // using the same template as article
this.render('article', {
controller: 'article.new'
});
},
model: function () {
return this.store.createRecord('article');
}
});
Edit: updated jsbin: http://emberjs.jsbin.com/aJATOhEp/4/edit?html,js,output Edit 2: latest working Ember.Select with a working selected option from model: http://emberjs.jsbin.com/aJATOhEp/11/edit?html,js,output