i able fill html select element knockout binding. of option texts include white spaces , i'd show them in dropdown.
in pure html can accomplished using instead of simple white spaces, that's not working knockout binding:
html:
knockout select: <select data-bind="options: entries" style="width: 150px"></select> <br> standard select: <select style="width: 150px"> <option> entry 1</option> <option> entry 2</option> </select> javascript:
var viewmodel = function() { entries = ko.observablearray([ ' entry 1', ' entry 2' ]); }; var vm = new viewmodel(); ko.applybindings(vm); hope can me this!
thanks
you can use regular foreach instead of options can set html content html binding on option elements:
<select data-bind="foreach: entries" style="width: 150px"> <option data-bind="html: $data"></option> </select> demo jsfiddle.
Comments
Post a Comment