Closed hegdeashwin closed 11 years ago
There's a few ways to populate - see the Select docs:
So in your case you can do:
var form = new Backbone.Form({
schema: {
/* Select Box */
SelectBox: {
type:'Select',
options: [
{ val: 1, label: 'Option Text 1' },
{ val: 2, label: 'Option Text 2' }
]
}
},
data: {
SelectBox: 'Option Text 3'
}
}).render();
$('#form-container').append(form.el);
ok; i got that. Thanks
Thanks as well. What if I want to add
<option selected="selected">3</option>
You'd set that as the form data, for example:
var form = new Backbone.Form({
schema: {
foo: { type: 'Select', options: [1,2,3,4] }
},
data: {
foo: 3
});
Or if you're using a model, set the 'foo' attribute to 3
I am not able to find any example or documentation regarding how to set values for select box options. Yes! options property sets options text but how to set values for respected options text. like E.g.
<option value="1">option1</option>