Created
December 1, 2010 16:28
-
-
Save eyeseast/723733 to your computer and use it in GitHub Desktop.
A tweet, as modeled in Backbone.js
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
// 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