Skip to content

Instantly share code, notes, and snippets.

@geekdave
Created April 9, 2012 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save geekdave/2344757 to your computer and use it in GitHub Desktop.
Save geekdave/2344757 to your computer and use it in GitHub Desktop.
Knockback: 2-way Data Binding with Knockout and Backbone
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>​
// create backbone model
var backboneModel = new Backbone.Model({
name: "Montgomery Burns",
age: 102,
evil: true
});
// set up knockback (kb) bridge
var viewModel = kb.viewModel(backboneModel, {
read_only: false
});
// engage knockout (ko) data bindings
ko.applyBindings(viewModel);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment