现在的位置: 首页 > 综合 > 正文

这年头居然连MSDN Library都靠不住呀

2014年01月20日 ⁄ 综合 ⁄ 共 994字 ⁄ 字号 评论关闭
   在做MS的相关开发时,MSDN Library简直就是圣经了,而且包括很多非M$的开发中,参考MSDN也是一件很有意义的事情。当然我们对于MSDN叙述的内容都是不容置疑的接受,可是今天发现MSDN也开始摆活了

    对于"DISABLED Attribute | disabled Property ",MSDN的Remarks如是说:

    When an element is disabled, it appears dimmed and does not respond to user input. Disabled elements do not respond to mouse events, nor will they respond to the contentEditable property.

    If an element's disabled property is set to false but it is contained within a disabled element, it cannot override the disabled state of its container.

    嗯,第一段说的是正确的,第二段就开始乱说了。其实他没说之前我也使这么理解的,因为IE使用bubble up方式处理事件,这样的效果也比较符合bubble up的设计,因为子元素的事件在bubble up到disabled的父元素上被ignore太正常了。

    看看下面的两个示例,DIV内部元素的event居然有的可以被ignore,有的可以继续bubble up,真 是乱。 
   

The DIV element is disabled.

The DIV element is disabled.



Checkbox


Radio Button

    绿框和蓝框都是被disabled=true的DIV元素,虽然里面的元素UI上都dimmed了,可是其上的event只有button、input type="checkbox"和input type="radio"被cancel了bubble up,而其的都可以正常的event bubble up,更甚至于input type="text"和input type="password"还可以继续编辑

    看来MSDN也有摆活的时候:( 所以处理container的disabled的时候一定要注意,最保险的是吧所有children都disabled掉,虽然麻烦些但保险哦。
 

抱歉!评论已关闭.