stopImmediatePropagation 与 stopPropagation 不同之处 请仔细查看加粗的文字并结合图例理解。
stopImmediatePropagation 防止对事件流中当前节点中和所有后续节点中的事件侦听器进行处理。此方法会立即生效,并且会影响当前节点中的事件侦听器。
stopPropagation 防止对事件流中当前节点的后续节点中的所有事件侦听器进行处理。此方法不会影响当前节点 (currentTarget
)
中的任何事件侦听器。
测试代码:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600"
initialize="application1_initializeHandler(event)">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
protected function application1_initializeHandler(event:FlexEvent):void
{
btn.addEventListener(MouseEvent.CLICK,handler1);
btn.addEventListener(MouseEvent.CLICK,handler2,false,1);
group.addEventListener(MouseEvent.CLICK,handler3);
this.addEventListener(MouseEvent.CLICK,handler4);
}
private function handler1(event:MouseEvent):void
{
trace("btn priority 0 handler");
event.stopPropagation();
}
private function handler2(event:Event):void
{
trace("btn priority 1 handler");
}
private function handler3(event:Event):void
{
trace("group handler");
}
private function handler4(event:Event):void
{
trace("app handler");
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:layout>
<s:VerticalLayout/>
</s:layout>
<s:Group id="group">
<s:Button label="Click" id="btn"/>
</s:Group>
</s:Application>
event.stopPropagation(),结果:
btn priority 1 handler
btn priority 0 handler
event.stopImmediatePropagation (),结果:
btn priority 1 handler
- 大小: 33.1 KB
分享到:
相关推荐
stopImmediatePropagation , stopPropagation和preventDefault其他事件选项 事件操作员对throttle和debounce支持 用于在NgZone外部NgZone并且仅在platformBrowser内部绑定的角度事件选项 该模块仅压缩3KB ,因此...
阻止冒泡:1、stopPropagation()对于非IE浏览器。2、cancelBubble属性为true,对于IE浏览器, 而Jquery已经有兼容浏览器的方法,event.stopImmediatePropagation(); <!DOCTYPE html> <html> <head>...
阻止冒泡:1、stopPropagation()对于非IE浏览器。2、cancelBubble属性为true,对于IE浏览器, 而Jquery已经有兼容浏览器的方法,event.stopImmediatePropagation(); 代码如下: <style> body { background:...
0},a.stopImmediatePropagation=function(){this.immediatePropagationStopped=this.propagationStopped=!0},a.remove=function(){this.removed=!0},a.clone=function(){return new Event(this.type,this.bubbles,...
1:阻止合成事件往最外层document上的事件冒泡,用e.nativeEvent.stopImmediatePropagation(); 2: 合成事件间的冒泡,使用 e.stopPropagation(); 3:阻止合成事件,往处理document上的其他原生事件冒泡,需要通过e....
e.stopImmediatePropagation(); obj.state.dragable = true; obj.state.mouseX = e.targetTouches[0].pageX; obj.state.mouseY = e.targetTouches[0].pageY; }); document.addEventListener("touchmove", ...
jquery需要的所有js文件 /*! * jQuery UI 1.8.18 * ... * Dual licensed under the MIT or GPL Version 2 licenses. ... * ... */(function(a,b){function d(b){return!a(b).parents().andSelf().filter(function(){return ...
(Bug) stopImmediatePropagation was not being honoured in live/delegate event handlers (#7217) (Bug) Fixed an issue where host and protocol were not compared case-insensitively when determining ...
(Bug) stopImmediatePropagation was not being honoured in live/delegate event handlers (#7217) (Bug) Fixed an issue where host and protocol were not compared case-insensitively when determining ...
stopImmediatePropagation(), stopPropagation(), eltarget, numtimeStamp, strtype, strwhich } Effects Basics $.show( [ duration [, easing] [, fn] ] ) $.hide( [ duration [, easing] [, fn] ] ) $.toggle( ...