最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - In Backbone.js, what are all events for the "binds"? - Stack Overflow

programmeradmin2浏览0评论
Collection.bind('change',this.function, this);
Collection.bind('add',this.function, this);
Collection.bind('remove',this.function, this);
Collection.bind('reset',this.function, this);

I know these four, but what are the rest?

What about model binds? What are the events for those?

How come I can't find a documentation specifying all the binds....

Collection.bind('change',this.function, this);
Collection.bind('add',this.function, this);
Collection.bind('remove',this.function, this);
Collection.bind('reset',this.function, this);

I know these four, but what are the rest?

What about model binds? What are the events for those?

How come I can't find a documentation specifying all the binds....

Share Improve this question asked Dec 7, 2011 at 7:44 TIMEXTIMEX 272k367 gold badges800 silver badges1.1k bronze badges 1
  • as Thilo says, they are in the FAQ, but keep in mind you can always .trigger('mycustomevent') and bind to your custom event too... you are not limited to the default events! it all depends what you are trying to achieve of course. – Sander Commented Dec 7, 2011 at 10:12
Add a comment  | 

1 Answer 1

Reset to default 25

It is a bit hidden in the FAQ.

  • "add" (model, collection) — when a model is added to a collection.
  • "remove" (model, collection) — when a model is removed from a collection.
  • "reset" (collection) — when the collection's entire contents have been replaced.
  • "change" (model, collection) — when a model's attributes have changed.
  • "change:[attribute]" (model, collection) — when a specific attribute has been updated.
  • "destroy" (model, collection) — when a model is destroyed.
  • "error" (model, collection) — when a model's validation fails, or a save call fails on the server.
  • "route:[name]" (router) — when one of a router's routes has matched.
  • "all" — this special event fires for any triggered event, passing the event name as the first argument.
发布评论

评论列表(0)

  1. 暂无评论