What are the base events by default?

Here I am a little lazy, but this is all (below) all the basic events by default. In addition, can I correctly say that the event bubble so that the collection will receive any events caused by the model.

Base Model Events
change
error
synchronization
destroy

Collection Events
add
remove
synchronization
reset

Thanks a lot Lazy Nick

+6
source share
2 answers

From the Backbone website ( http://backbonejs.org/#Events-catalog ):

Event catalog

Here is a list of all the built-in events that can trigger Backbone.js. You can also trigger your own events on models and views as you wish.

  • "add" (model, collection, parameters) - when adding a model to the collection.
  • β€œdelete” (model, collection, parameters) - when the model is deleted from the collection.
  • "update" (collection, parameters) - one event is triggered after adding or removing any number of models from the collection.
  • "reset" (collection, parameters) - when replacing all content.
  • "sort" (collection, parameters) - when the collection was re-sorted.
  • "change" (model, parameters) - when changing the attributes of the model.
  • "change: [attribute]" (model, value, parameters) - when updating a specific attribute.
  • "destroy" (model, collection, options) - upon destruction of the model.
  • "request" (model_or_collection, xhr, options) - when the model or collection launched a request to the server.
  • "sync" (model_or_collection, resp, options) - when the model or collection was successfully synchronized with the server.
  • "error" (model_or_collection, resp, options) - when the request of the model or collection to the server failed.
  • "invalid" (model, error, parameters) - when the model check is not performed on the client.
  • "route: [name]" (params) - launched by the router when matching a specific route.
  • "route" (route, parameters) - launched by the router when matching any route.
  • "route" (router, route, parameters) - launched by history when matching any route.
  • "all" - this special event is triggered for any triggered event, passing the name of the event as the first argument.

As for the event bubbles, then yes. When a model event fires, it usually bubbles up the collection. I am not 100% sure if this is the case in 100% of cases, but usually it is, at least for inline events.

+8
source

Currently the URL is different: http://backbonejs.org/#Events-catalog

Backbone.js event list row:

  • "add" (model, collection, parameters) - when the model is added to the collection.
  • "remove" (model, collection, options) - when the model is removed from the collection.
  • "reset" (collection, parameters) - when replacing the entire contents of the collection.
  • "sort" (collection, options) - when the collection was re-sorted.
  • "change" (model, options) - when changing the attributes of the model.
  • "change: [attribute]" (model, value, parameters) - when updating a specific attribute.
  • "destroy" (model, collection, options) - when the model is destroyed.
  • "request" (model_or_collection, xhr, options) - when the model or collection launched a request to the server.
  • "sync" (model_or_collection, resp, options) - when the model or collection was successfully synchronized with the server.
  • "error" (model_or_collection, resp, options) - when the request of the model or collection to the remote server failed.
  • "invalid" (model, error, parameters) - when the model check is not performed on the client.
  • "route: [name]" (params) - launched by the router when matching a specific route.
  • "route" (route, params) - launched by the router when any route is agreed.
  • "route" (router, route, parameters) - started by history when any route was mapped.
  • "all" - this special event is triggered for any triggered event, passing the name of the event as the first argument.
+4
source

Source: https://habr.com/ru/post/911389/


All Articles