lundi 23 mars 2015

Ember.js load extra dataset for select

I'm trying to get a select box appear for a bunch of data extra which is selected using a <select> box like so:



{{view "select" content=banks
optionLabelPath="content.name"
optionValuePath="content._id"
selection="content._id"
value=data.bank}}


And I'm populating banks like so:



var AccountsEditController = Ember.ObjectController.extend({
banks : [],
init : function(){
this._super();

var self = this;
Ember.$.getJSON("/admin_api/banks", function(rsp){
self.set("banks", rsp.data);
});
},
// ...
});


However, when the banks gets updated, a previous value for data.bank isn't selected, which means pressing save produces a incorrect result. Also the value seems to reset to null on the actual data binding. I'm also not too sure if the way I'm populating the data is correct (I don't wish to use Ember Data).





Aucun commentaire:

Enregistrer un commentaire