Created
April 9, 2012 17:02
-
-
Save geekdave/2344757 to your computer and use it in GitHub Desktop.
Knockback: 2-way Data Binding with Knockout and Backbone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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