Hello,
I have a problem =) I wish to add existing items to List when my model is fetched.
I have such a model:
app.Role = Backbone.Model.extend({
urlRoot: '/roles/rest',
default:{
permissionList:[165]
},
schema: {
definition: { },
permissionList: {type: 'List', itemType:'Select', options: new app.PermissionsCollection() }
},
parse: function(response) {
return response.data;
}
});
PermissionsCollection is fetched from server
Now I wish to render a form and prepopulate my List with permissions, which role already has. How to do it?
This approach is not working:
var form = new app.EditForm({
model: model,
template: _.template($('#'+keyword+'-form-template').html())
}).render();
app.CurrentView = form;
$('#inner-content').html(form.el);
model.on('change', function(model) {
_.each(model.attributes, function(el,key,list){
var data = {};
data[key] = el;
app.CurrentView.setValue(data);
});
});