How to bind data on a Handlebars.js template for automatic value update?

Alejandro García Iglesias picture Alejandro García Iglesias · Apr 24, 2012 · Viewed 25.1k times · Source

There are many JavaScript MVC frameworks right now that work with Handlebars.js offering data binding between the model/controller and the template. Currently I'm implementing Handlebars.js alone (with jQuery) and needing to bind data between my main code and the template so the latter gets updated automatically. Is there a native way to do it in Handlebars or with a plugin? If there isn't, is there any component of these MVC frameworks that brings this functionality and can be used stand-alone without the full-stack framework?

Answer

bigspotteddog picture bigspotteddog · Feb 9, 2013

Take a look at rivets: https://github.com/mikeric/rivets. I use backbone, handlebars, and backbone.modelbinding for two-way updates. Works great.

Backbone.modelbinding (https://github.com/derickbailey/backbone.modelbinding) has been abandoned, but refers to rivets.