Created
December 11, 2012 20:13
-
-
Save michaelcox/4261745 to your computer and use it in GitHub Desktop.
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
class view extends Backbone.View | |
initialize: => | |
@template = _.template($('#mytemplate').html()) | |
render: => | |
@$el.html @template( | |
model: @model.toJSON() | |
) |
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
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() | |
})); | |
} | |
}); |
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
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