Created
November 1, 2011 23:35
-
-
Save nhunzaker/1332280 to your computer and use it in GitHub Desktop.
Article 1 - Example of Events
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 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