Data binding with plugins

As you can see in the previous section, Backbone does not provide an easy mechanism to sync your models and the views that use them. Some plugins for Backbone have been developed to minimize this issue; one of them is Backbone.Stickit.

If you want an easy and yet powerful way to bind DOM nodes and Backbone models, Backbone.Stickit will do a great job:

var FormView = ModelView.extend({
template: '#form-template',
  bindings: {
    '#name': 'name',
    '#phone': 'phone',
    '#email': 'email'
  },
  onRender: function() {
    this.stickit();
  }
});

The preceding code example shows how it looks; please consult the project documentation to learn more about it.

Get Mastering Backbone.js now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.