backbone-1.3.3 Source parsing-----------Event

Source: Internet
Author: User

The first time, write wrong, please correct me.

The event in Backbone.js implements the custom events. A custom event is a key-value pair for an object, key is the event name, and value is a function array. There is a built-in object in the backbone object _events holds all the events

View Code

All events methods are called through EVENTSAPI.

Eventsapi = function (iteratee, events, name, callback, opts) {...}

The OFFAPI,ONCEMAP,TRIGGERAPI is passed in as the first parameter of EVENTSAPI to achieve the off,once,trigger of sexual. Where on and Listento are called by the Internalon method, the Eventsapi,internalon method is to differentiate on and listento by a fifth parameter. The purpose of the Internalon method is to protect the fifth parameter and improve security.

Here are 3 properties of this._events={eventname:[]} and This._listeningto={obj._listenid:{obj:obj, Objid:id, Id:thisid, ListeningTo: Listeningto, count:0}} and This._listeners={obj._listenid:{obj:obj, Objid:id, Id:thisid, Listeningto:listeningto, Count : 0}, these three are map objects. The events class eventually implements operations on these 3 objects.

Note: Events.listento = function (obj, name, callback) {...} This method invokes the This._events,this._listeningto and Obj._listeners three properties at a time

backbone-1.3.3 Source parsing-----------Event

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.