看看这个使用淘汰赛和主干的小提琴,这些库是自动导入的吗?
Code here :
Name: <input data-bind="value: name" type="text"/><br>
Age: <input data-bind="value: age" type="text"/><br>
Evil: <input type="checkbox" data-bind="checked: evil" /><br>
<button id="foo">Change Model!</button>
// create a plain old backbone model
var backboneModel = new Backbone.Model({
name: "Montgomery Burns",
age: 102,
evil: true
});
// use knockback.js to bridge knockout data-binding with backbone models
// read_only is set to false to make the binding two-way.
// note the use of the "kb" api for knockback.
var viewModel = kb.viewModel(backboneModel, {
read_only: false
});
// at this point, knockback has given us a viewModel which is compatible
// with the normal knockout api. so we can use the "ko" api now.
ko.applyBindings(viewModel);
$("#foo").click(function() {
backboneModel.set ({
"name": "Lisa Simpson",
"age": 8,
"evil": false
});
});