Knockback.js provides Knockout.js magic for Backbone.js Models and Collections.
Pull request Compare This branch is 683 commits behind kmalakoff:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Build Status

    __ __                  __   __               __       _
   / //_/____  ____  _____/ /__/ /_  ____ ______/ /__    (_)____
  / ,<  / __ \/ __ \/ ___/ //_/ __ \/ __ `/ ___/ //_/   / / ___/
 / /| |/ / / / /_/ / /__/ ,< / /_/ / /_/ / /__/ ,< _   / (__  )
/_/ |_/_/ /_/\____/\___/_/|_/_.___/\__,_/\___/_/|_(_)_/ /____/

Knockback.js provides Knockout.js magic for Backbone.js Models and Collections.


You can get the library here:

NOTE: there are breaking changes in 0.15.+ Please see the [release notes][] for details.


Why Write Knockback.js?

When I was evaluating client-side frameworks, I liked lots of the pieces, but wanted to "mix and match" the best features. I started with Backbone.js and really loved the Models and Collections, and used Brunch to get me up and running quickly.

After a while, I found the view coding too slow so I wrote Mixin.js to extract out reusable aspects of my views. When I was looking for my next productivity increase, an ex-work colleague suggested Sproutcore, but at the time, it wasn't yet micro-frameworky enough meaning I would need to learn something big and "to throw the baby out with the bathwater" as they say (it is hard to give up Backbone models and collections!). Then, I discovered Knockout and knew it was for me!

Knockout provided just the right building blocks for a layer between my templates and data. As I used it more, I built additional functionality like Backbone.ModelRefs for lazy model loading, localization helpers for truly dynamic views, and most recently, an easier way to sync collections and their model's view models.

So here it is...the refactored and shareable version of my Backbone bindings for Knockout: Knockback.js



An Example

The view model:

ContactViewModel = (model) ->
  kb.observables(model, {
    name:     'name'
    email:    {key:'email', default: ''}
    date:     {key:'date', localizer: LongDateLocalizer}
  }, this)
  @           # must return this or Coffeescript will return the last statement which is not what we want!

or (Coffeescript)

class ContactViewModel extends kb.ViewModel
  constructor: (model) ->
    super(model, {internals: ['email', 'date']})  # call super constructor: @name, @_email, and @_date created in super from the model attributes
    @email = kb.defaultWrapper(@_email, '')
    @date = new LongDateLocalizer(@_date)

or (Javascript)

var ContactViewModel = kb.ViewModel.extend({
  constructor: function(model) {, model, {internals: ['email', 'date']});   // call super constructor: @name, @_email, and @_date created in super from the model attributes = kb.defaultWrapper(this._email, ''); = new LongDateLocalizer(this._date);
    return this;


<label>Name: </label><input data-bind="value: name" />
<label>Email: </label><input data-bind="value: email" />
<label>Birthdate: </label><input data-bind="value: date" />


view_model = new ContactViewModel(new Backbone.Model({name: 'Bob', email: '', date: new Date()}))

# ...

# and cleanup after yourself when you are done.

And now when you type in the input boxes, the values are properly transferred to the model and the dates are even localized!

Of course, this is just a simple example, but hopefully you get the picture.

Demos and Documentation

For comprehensive tutorials, take a look at the website:

Try a live demo: or

Building, Running and Testing the library


  1. install node.js:
  2. install node packages: 'npm install'


Look at: