msenkpiel
3/7/2014 - 3:30 PM

backbone default view

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();
    }
});