Skip to content

Instantly share code, notes, and snippets.

@msenkpiel
Last active August 29, 2015 13:57
Show Gist options
  • Save msenkpiel/9413569 to your computer and use it in GitHub Desktop.
Save msenkpiel/9413569 to your computer and use it in GitHub Desktop.
backbone default view
MyView = Backbone.View.extend({
options:{},
className: '',
events: {
},
initialize: function (options) {
if(options){
_.extend(this.options, options);
}
this.render();
},
render: function () {
$('body').append(this.$el.html(this.template()));
this.afterRender();
return this;
},
template: function () {
var template = Handlebars.compile($('#viewTpl').html());
return template(); // returned rendered html
},
afterRender:function(){
},
destroy: function () {
this.unbind();
this.remove();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment