JavaScript Event: JQuery.event.remove Event explanation

Source: Internet
Author: User

We've already introduced JQuery.event.add, so let's take a look at jQuery.event.remove.

First on the code

  

/*elem: Handled element types: Removed event handler: Removed method selector: element mappedtypes of the delegate:*/Remove:function(Elem, types, Handler, selector, mappedtypes) {varJ, Origcount, TMP, events, T, Handleobj, special, handlers, type, namespaces, Origtype,//get the data cache bound on the ElemElemdata = Data_priv.hasdata (elem) &&Data_priv.get (Elem); //no elemdata or elemdata.events, Exit function    if(!elemdata | |! (Events =elemdata.events)) {return; }    //handling Multi-event operations separated by spacesTypes = (Types | | ""). Match (core_rnotwhite) | | [""]; T=types.length;  while(t-- ) {        //TypeNamespace =/^ ([^.] *)(?:\. (.+)|) $/;TMP = Rtypenamespace.exec (types[t]) | | []; Type= Origtype = Tmp[1]; Namespaces= (Tmp[2] | | ""). Split (".")). sort (); //Remove all events under this element        if( !type) {             for(Typeinchevents) {JQuery.event.remove (elem, type+ types[T], handler, selector,true ); }            Continue; } Special= jquery.event.special[Type] | | {}; Type= (selector? special.delegateType:special.bindType) | |type; Handlers= events[Type] | | []; //If there is a namespace, get a regular with a namespaceTMP = tmp[2] &&NewRegExp ("(^|\\.)" + namespaces.join ("\ \ (?:. *\\.|)") + "(\\.| $)" ); Origcount= j =handlers.length;  while(j-- ) {            //get a handleobj under the handlersHandleobj =handlers[J]; if((mappedtypes | | origtype = = = Handleobj.origtype) &&                ( !handler | | Handler.guid = = = Handleobj.guid) &&                ( !tmp | | Tmp.test (handleobj.namespace)) &&                ( !selector | | selector = = = Handleobj.selector | | selector = = = "*" &&handleobj.selector)) {//remove the corresponding event object from the handlersHandlers.splice (J, 1 ); //Handling Delegatecount                if(handleobj.selector) {Handlers.delegatecount--; }                //If you have remove under Specia, call                if(special.remove) {Special.remove.call (Elem, handleobj); }            }        }        //Remove Generic event handler if we removed something and no more handlers exist        //(avoids potential for endless recursion during removal of special event handlers)        if(Origcount &&!)handlers.length) {if(!special.teardown | | special.teardown.call (elem, namespaces, elemdata.handle) = = =false) {jquery.removeevent (Elem, type, elemdata.handle); }            //Remove the Evens type            Deleteevents[type]; }    }    //Remove The expando if it ' s no longer used    if(Jquery.isemptyobject (events)) {DeleteElemdata.handle; Data_priv.remove (Elem,"Events" ); }},

JavaScript Event: JQuery.event.remove Event explanation

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.