Knockback.js: You got your Knockout in my Backbone
I’m really excited about releasing this. Knockback.js provides Backbone model and collection bindings for Knockout.
This means you can now put different views of the same models on your web page and they can automatically update…one or two way, and localization is a breeze. Take a look at this jsFiddle: http://jsfiddle.net/kmalakoff/QSkpv/ and you can see:
- it dynamically localizes all the labels and event the text inputs
- it dynamically sorts the model views based on the sortedIndex function
- all changes in a model are updated in real time using Knockout bindings
Example: A simple model attributes binding
The view model:
ContactViewModel = (model) ->
kb.observables(model, {
name: {key:'name'}
email: {key:'email', write: true, default: 'your.name@yourplace.com'}
date: {key:'date', write: true, localizer: LongDateLocalizer}
}, this)
The HTML:
<label>Name: </label><input data-bind="value: name" />
<label>Email: </label><input data-bind="value: email" />
<label>Birthdate: </label><input data-bind="value: date" />
And...engage:
view_model = new ContactViewModel(collection.get('some_id'))
ko.applyBindings(view_model)
You can find this example and more here: https://github.com/kmalakoff/knockback
Download now (Right-click, and use “Save As”):
-
Development: knockback.js
-
Production: knockback.min.js
Knockback.js works with both Knockout1.2.1 and Knockout1.3
(Source: kmalakoff.github.com)