Skip to content

Instantly share code, notes, and snippets.

@eyeseast
Created December 1, 2010 16:28
Show Gist options
  • Save eyeseast/723733 to your computer and use it in GitHub Desktop.
Save eyeseast/723733 to your computer and use it in GitHub Desktop.
A tweet, as modeled in Backbone.js
// Models
var Tweet = Backbone.Model.extend({
initialize: function(attrs) {
// add in a few helper attributes
if (attrs.text) {
this.set({
html: twttr.txt.autoLink(attrs.text),
timestamp: Date.parse(attrs.created_at).setTimezone('GMT')
}, {
silent: true
});
};
// set a default view for this tweet
this.view = new TweetView({
model: this
});
},
url: function() {
return "http://twitter.com/" + this.get('from_user') + "/statuses/" + this.get('id');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment