Created
April 10, 2013 22:52
-
-
Save bloudermilk/5359161 to your computer and use it in GitHub Desktop.
Backbone extension to bind roles to Views
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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