Event registration and calling sequence in extjs

Source: Internet
Author: User
I saw a good example when I was reading extjs today. Let's talk about how to register and delete a browser.

For example:

<Input type = "button" id = "button1" value = "Click me"/> <input type = "button"

Id = "button2" value = "move above me"/> </center>

<SCRIPT>

Function buttononclick1 () {alert ('triggered when the first click event registered with extjs ')}

Function buttononclick2 () {alert ('triggered by the second click event registered with extjs ')}

Function Init ()

{

VaR button1 = ext. Get ('button1 ');

VaR button2 = ext. Get ('button2 ');

Button1.on ('click', buttononclick1 );

Button1.on ('click', buttononclick2 );

Button2.on ('mousemove ', function (OBJ) {alert (button2.getvalue (); button1.un ('click', buttononclick2 )});

}

Ext. onready (init );

</SCRIPT>

Note:

Button2.on ('mousemove ', function (OBJ) {alert (button2.getvalue (); button1.un ('click', buttononclick2 )});

When you click button1, The buttononclick2 () event is triggered first, because in extjs, It is triggered first after registration,

Therefore, the second click event registered with extjs is triggered first, and the first click event registered with extjs is triggered ';

Then, the "UN" event cancels the "buttononclick2" event in "button1". So when you move the mouse over "button2" and then click the first button, the first click event registered with extjs is triggered'

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.