backbone-decorator

0.0.1 • Public • Published

Backbone Decorator

If you have lot's of data in your templates that needs formatting or just a seperate way of displaying your model in one View or another.

Decorators are very usefull if you have a events-rich View, which ussually have quite some template data aswell. The Decorator is here to keep your Views focussed on the events and all supporting functions around the those events.

Example:

 
    App.ProductsView = Backbone.View.extend({
      // decorator is assigned here
      decorator: App.ProductsDecorator,
 
      initialize: function() {
        this.listenTo(this.model, '...', this.someFunc);
      },
 
      events: {
        // some lot's of events here
        '...': '...'
      },
 
      // some lots of functions to support event-functions here
 
      render: function() {
        // getTemplateData is injected into Backbone.View
        // because a decorator is assigned.
        var data = this.getTemplateData();
        this.el.html(template(data));
      }
 
    });
 

Readme

Keywords

Package Sidebar

Install

npm i backbone-decorator

Weekly Downloads

1

Version

0.0.1

License

MIT

Last publish

Collaborators

  • angelomichel