Skip to content

Instantly share code, notes, and snippets.

@yaotti
Created December 6, 2011 10:29
Show Gist options
  • Save yaotti/1437699 to your computer and use it in GitHub Desktop.
Save yaotti/1437699 to your computer and use it in GitHub Desktop.
Backbone.jsでモデルとビューを分離しやすくするためにadd/resetイベントを活用 ref: http://qiita.com/items/1304
model.bind('hoge', function () {
alert('hogeされた');
});
model.trigger('hoge'); // => alert('hogeされた');
var items = new Backbone.Collection;
items.bind("add", function(item) {
alert("New item is added: " + item.title);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment