Last active
August 29, 2015 13:57
-
-
Save msenkpiel/9413569 to your computer and use it in GitHub Desktop.
backbone default view
This file contains 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
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