I\'m using Backbone and therefore Underscore to render my templates. My templates get rendered in tags and then I use jQuery to grab their html. My
You could store the compiled template in a closure so that only the instances of ItemView can access it:
(function() {
var template;
App.ItemView = Backbone.View.extend({
className:'well',
events: {
'click .continue': 'handleContinueClick'
},
initialize: function() {
this.render();
},
render: function() {
template = template || _.template($("#ItemTemplate").html());
$(this.el).html(template({model:this.model}));
},
handleContinueClick: function(e) {
alert('Clicked!');
}
});
})();