Skip to content

Instantly share code, notes, and snippets.

@aroman
Created May 13, 2012 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aroman/2670307 to your computer and use it in GitHub Desktop.
Save aroman/2670307 to your computer and use it in GitHub Desktop.
<script id="conversation-stub-template" type="text/x-handlebars-template">
<td>Unread count: {{unread}}</td>
<td>{{last_message}}</td>
</script>
conversation_stub_template = Handlebars.compile($("#conversation-stub-template").html());
ConversationStubView = Backbone.View.extend({
tagName: 'tr',
template: conversation_stub_template,
events: {
"click": "showConversation",
"click button.delete": "remove"
},
initialize: function (options) {
this.render();
this.model.on("change:unread", this.render, this);
},
destroy: function () {
this.model.off("change:unread", this.render);
},
render: function () {
// this.$el.html(this.template(this.model.toJSON()));
$(this.el).html(this.template(this.model.toJSON()));
return this;
},
showConversation: function () {
// Create the conversation view and stick
// it in the DOM here.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment