The most common thing to do is to register the event handler, because in the ExtJS world, it is almost entirely composed of time. The following is a case of the handler. If you are interested, refer to the following, I hope that the most common thing you do when designing ExtJS applications is to register the event handler, because in the ExtJS world, it is almost entirely composed of time. Therefore, the ExtJS designer makes it very easy to register events (and also provides a very difficult way for you to choose) -- on/un, that is, the upper and lower ways, or addListener and removeListener can be used by all subclasses of Element. For example
We hope you can give simple feedback when you press the button:
How to replace this
Register the mouse click event? First, you must obtain the Element instance of this p:
VarhappyDiv = Ext. get ('happydiv ');
Then define the event handler:
The Code is as follows:
VarclickHandler = function (event, eventTarget ){
Ext. MessageBox. alert ("Click", "Youclicked:" + eventTarget. id );
}
Use on () to connect the event handler function with the Element instance:
The Code is as follows:
HappyDiv. on ('click', clickHandler );
When the program is executed, click
The result shown in-15 is displayed.
Very simple, right? The sample file is ch03/event_demo.html. To remove this event handler, you only need to change on () to un. There is no event handler corresponding to the click event when the event is removed, and the underlying EventManager will determine it by itself. When an event handler is called, it receives three parameters: event, eventTarget, and optionObj. In this example, only two parameters are used. The third parameter is described when EventManager is discussed. Focus on event and eventTarget. The event type is Ext. Event, and eventTarget is an HTML element. When the browser Press
When the click event is triggered and clickHanlder () is called, for clickHanlder (), the event received is the click event triggered by the browser. EvnetTarget is the event target, that is
The value of eventTarget. id is "happyDiv ". Where should I find the root class of the event? Answer