knockout.js - Unable to work out simple helloworld example of KnockOut -
i trying use knockout despite simple code unable select list populated. below code, can point out doing wrong
<html> <head> <script type="text/javascript" src="knockout-3.3.0.js"> </head> <body> <script type="text/javascript"> var listeditorviewmodel = function () { this.allitems = ko.observablearray(["apple"]); } ko.applybindings(document.body,new listeditorviewmodel()); </script> <div>this select populated</div> <select multiple="multiple" data-bind="options: allitems"></select> </body> </html>
your parameter order in applybindings
incorrect - first parameter must model , second parameter dom element. update code this:
ko.applybindings(new listeditorviewmodel(), document.body);
or omit second parameter, because binding document anyway:
ko.applybindings(new listeditorviewmodel());
Comments
Post a Comment