tag (backbone)

archive

bind a model's .change() trigger to a view's .render() function in backbone Jul
06
1
2

You can bind a Model's .change() trigger to a View's .render() function in Backbone by using the bindAll method to make sure the render method is always bound to the view.

MyView = Backbone.View.extend({
    initialize: function() {
        _.bindAll(this, "render");
        this.model.bind('change', this.render);
    },

    render: function() {
        this.model.$el.html(this.template(this.model.toJSON()));
        return this;
    }
});

comments