I have been trying to decipher backbone.relational source code. I found that it fires a lot of its own events. I did a log on some of my models, and found that a lot of these events seem to fire off for no reason.
Big question is which events should I listen to and which are internal events
The events that Backbone.Relational seems to fire are:
- update:[attribute] seems to fire [Line 725, 941]
- relational:add This one seems to fire when .add() is called on a collection
- relational:remove This one seems to fire when .remove() is called on a collection [1651, 1003]
- relational:reset This one seems to have no rhyme or reason (why is being fired on sort!!!) [1664, 1675]
- relational:change:[attribute]: Have no idea what this does [1138]
Can someone explain what the purpose of each is and if some of the triggers can be removed from source
For comparison, Backbone's native events:
- "add" (model, collection, options) — when a model is added to a collection.
- "remove" (model, collection, options) — when a model is removed from a collection.
- "reset" (collection, options) — when the collection's entire contents have been replaced.
- "sort" (collection, options) — when the collection has been re-sorted.
- "change" (model, options) — when a model's attributes have changed.
- "change:[attribute]" (model, value, options) — when a specific attribute has been updated.
- "destroy" (model, collection, options) — when a model is destroyed.
- "request" (model, xhr, options) — when a model (or collection) has started a request to the server.
- "sync" (model, resp, options) — when a model (or collection) has been successfully synced with the server.
- "error" (model, xhr, options) — when a model's save call fails on the server.
- "invalid" (model, error, options) — when a model's validation fails on the client.
- "route:[name]" (params) — Fired by the router when a specific route is matched.
- "route" (router, route, params) — Fired by history (or router) when any route has been matched.
- "all" — this special event fires for any triggered event, passing the event name as the first argument.