0.0.3 • Published 10 years ago

backbone-viewstate v0.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
10 years ago

Backbone ViewState

To use for Backbone.Views, the ViewState keeps data/attributes in a Backbone.View you don't want in your Backbone.Model.

Instead of using the View itself to keep data, a ViewState is the place where you set/get all attributes. All ViewState attributes are passed to your render's template as template data.

For example in some Backbone.View:

    initialize: function() {
      this.viewState = new Backbone.ViewState();
    },

    getTemplateData: function() {
      return _.extend(
        this.model.toJSON(),
        this.viewState.getAttributes()
      );
    },

    render: function() {
      this.el.html(template(this.getTemplateData()));
    }