Events are capable of binding objects and trigger custom events i.e. you can bind the custom events by using desired name of our choice.
Following table lists down all the methods which you can use to manipulate the BackboneJS-Events:
S.N. | Methods & Description |
---|---|
1 | on It binds an event to an object and executes the callback whenever an event is fired. |
2 | off It removes callback functions or all events from an object. |
3 | trigger It invokes the callback functions for the given events. |
4 | once It extends backbone.Model class while creating your own backboneModel. |
5 | listenTo It informs one object to listen an event on another object. |
6 | stopListening It can be used to stop listening to events on the other objects. |
7 | listenToOnce It causes the listenTo occur only once before the callback function is being removed. |
Catalog of Built-in Events
BackboneJS allows use of global events wherever necessary in your application.It contains some of the built-in events with arguments as shown in the below table:
S.N. | Events & Description |
---|---|
1 | "add"(model, collection, options) It used when model is added to the collection. |
2 | "remove"(model, collection, options) It removes the model from the collection. |
3 | "reset"(collection, options) It is used to resets the collection contents. |
4 | "sort"(collection, options) It is used when collection needs to resorted. |
5 | "change"(model, options) It is used when changes in model's attributes. |
6 | "change:[attribute]"(model, value, options) It is used when there is an update in an attribute. |
7 | "destroy"(model, collection, options) It fires when model is destroyed. |
8 | "request"(model_or_collection, xhr, options) It is used model or colection starts requesting to the server. |
9 | "sync"(model_or_collection, resp, options) It is used when model or collection synced successfully with server. |
10 | "error"(model_or_collection, resp, options) It activates when there is an error in requesting to the server. |
11 | "invalid"(model, error, options) When there is a fail in model validation, it returns invalid. |
12 | "route:[name]"(params) When there is a specific route match, this event can be used. |
13 | "route"(route,params) It is used when there is a match with any route. |
14 | "route"(router, route, params) It is used by history when there is a match with any route. |
15 | "all" It fires for all triggered event by passing event name as first argument. |
No comments:
Post a Comment