Skip to content

Instantly share code, notes, and snippets.

@bloudermilk
Created April 10, 2013 22:52
Show Gist options
  • Save bloudermilk/5359161 to your computer and use it in GitHub Desktop.
Save bloudermilk/5359161 to your computer and use it in GitHub Desktop.
Backbone extension to bind roles to Views
// Automatically instantiates views based on the `role` attribute.
//
// Example:
// AA.Views.Workflow = Backbone.View.extend();
// AA.Views.Workflow.bindRole("workflow");
Backbone.View.bindRole = function (role) {
var view = this;
$(function () {
$("@" + role).each(function () {
new view({ el: this }).render();
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment