Skip to content

Instantly share code, notes, and snippets.

@nhunzaker
Created November 1, 2011 23:35
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 nhunzaker/1332280 to your computer and use it in GitHub Desktop.
Save nhunzaker/1332280 to your computer and use it in GitHub Desktop.
Article 1 - Example of Events
var Tweet = Backbone.Model;
var tweetsCollection = new Backbone.Collection({
model: Tweet,
initialize: function() {
this.bind('add', function(model) {
alert("Oh snap, we have a model!");
});
}
});
// Will fire the 'add' event of the TweetsCollection
tweetsCollection.add({
from_user : "natehunzaker",
text : "Grow your JS a #backbone for great good!"
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment