List of all built-in/default events in Backbone.js?

Answered
nick asked this question 11 months ago
nick on Mar 7, 2022

What are all the built-in events that Backbone.js provides by default?

Is there a list of them somewhere that I can view? Or can someone provide the list?

Thanks in advance! Haven't been able to find this anywhere.

2 suggested answers
moon_man41 on Mar 7, 2022

You can find that list in the Backbone.js documentation: http://backbonejs.org/#Events-catalog.

0 replies
coderguy on Mar 7, 2022

Here's the list (found here):

  • "add" (model, collection, options) — when a model is added to a collection.
  • "remove" (model, collection, options) — when a model is removed from a collection.
  • "update" (collection, options) — single event triggered after any number of models have been added, removed or changed in a collection.
  • "reset" (collection, options) — when the collection's entire contents have been reset.
  • "sort" (collection, options) — when the collection has been re-sorted.
  • "change" (model, options) — when a model's attributes have changed.
  • "changeId" (model, previousId, options) — when the model's id has been updated.
  • "change:[attribute]" (model, value, options) — when a specific attribute has been updated.
  • "destroy" (model, collection, options) — when a model is destroyed.
  • "request" (modelorcollection, xhr, options) — when a model or collection has started a request to the server.
  • "sync" (modelorcollection, response, options) — when a model or collection has been successfully synced with the server.
  • "error" (modelorcollection, xhr, options) — when a model's or collection's request to the server has failed.
  • "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" **(route, params) — Fired by the router when any route has been matched.
  • "route" (router, route, params) — Fired by history when any route has been matched.
  • "all" — this special event fires for any triggered event, passing the event name as the first argument followed by all trigger arguments.
0 replies
Answered