jeudi 22 janvier 2015

Ember.Select doesn't initiate list according to 'selectionBinding'

I have many to many relationship between books and their authors. Every book has a collection of associated authors (and vice versa). On book's edit page I am displaying a multiple selection, but the problem is that the selection doesn't show authors associated with the book I am currently editing, instead there is just a list with no selected options. Then I can select authors and it's working just alright, it's just that the initial state of 'select' component gets erased (it also clears the collection of authors. If I enter the edit page and navigate to somewhere else without selecting any authors suddenly book that had a few authors doesn't have any of them anymore).


Here is the select snippet from template:



{{view "select" class="form-control"
multiple=true
contentBinding="allAuthors"
optionLabelPath="content.fullName"
optionValuePath="content.id"
selectionBinding="model.authors"}}


All authors are put into the controller at route's setupController hook, like this:



App.BookEditRoute = Ember.Route.extend({
setupController: function(controller, model) {
controller.set('model', model);
controller.set('allAuthors', this.store.find('author'))
}
})


And obviously controller's model has authors property inherited from parent controller.





Aucun commentaire:

Enregistrer un commentaire