generator-stacked
Version:
A Backbone.js Require.js test driven workflow.
46 lines (28 loc) • 1.11 kB
JavaScript
// IndexView.js
define(["jquery", "backbone", "models/<%= path %><%= initName %>Model", "text!templates/<%= path %><%= initName %>.html"],
function($, Backbone, Model, template){
var <%= initName %>View = Backbone.View.extend({
// The DOM Element associated with this view
el: ".magic",
// View constructor
initialize: function() {
// Calls the view's render method
this.render();
},
// View Event Handlers
events: {
},
// Renders the view's template to the UI
render: function() {
// Setting the view's template property using the Underscore template method
this.template = _.template(template, {});
// Dynamically updates the UI with the view's template
this.$el.html(this.template);
// Maintains chainability
return this;
}
});
// Returns the View class
return <%= initName %>View;
}
);