By default, a click event is triggered when you double-click an event, but this is sometimes not what we want, so how can we block the trigger of the click event when double-clicking? There is a method to delay execution circulating on the Internet. The general idea is as follows: by default, when double-clicking an event, the click event is triggered, but sometimes this is not what we want, so how can we block the trigger of the click event when double-clicking? There is a method of delayed execution circulating on the Internet. The general idea is as follows:
1. Declare a global timer variable such as clickTimer.
2. Set the timer in the event clicked by the proxy. The default setting is 220 milliseconds, which triggers the real click event processing function.
3. Judge the timer variable in the double-click event. If the variable is not NULL, it indicates that the click event is triggered before the double-click event is triggered to cancel the timer, because the real click event processing function is triggered after 220 milliseconds, when the timer is completed, the real click event processing function will not be executed.
Code attached:
1var timerClick = null;
2 // Click Event proxy
3 function _ onNodeClick (id ){
4 // onNodeClick is the real Click Event Processing Function
5 timerClick = window. setTimeout ("onNodeClick ('" + id + "')", 220 );
6}
7 // double-click the event processing function
8 function _ onNodeDbClick (id ){
9 if (timerClick ){
10 window. clearTimeout (timerClick );
11}
12}
The above content does not trigger the onClick event when onDbClick is triggered by latency. For more information, see www.php1.cn)