Skip to content

Instantly share code, notes, and snippets.

@michaelcox
Created December 11, 2012 20:13
Show Gist options
  • Save michaelcox/4261745 to your computer and use it in GitHub Desktop.
Save michaelcox/4261745 to your computer and use it in GitHub Desktop.
class view extends Backbone.View
initialize: =>
@template = _.template($('#mytemplate').html())
render: =>
@$el.html @template(
model: @model.toJSON()
)
var view = Backbone.View.extend({
initialize: function() {
_.bindAll(this);
this.template = _.template($('#mytemplate').html());
},
render: function() {
this.$el.html(this.template({
model: this.model.toJSON()
}));
}
});
var view,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
view = (function(_super) {
__extends(view, _super);
function view() {
return view.__super__.constructor.apply(this, arguments);
}
view.prototype.initialize = function() {
return this.template = _.template($('#mytemplate').html());
};
view.prototype.render = function() {
return this.$el.html(this.template({
model: this.model.toJSON()
}));
};
return view;
})(Backbone.View);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment