【问题标题】:How to prevent event bubbling, rightnavbutton? Titanium如何防止事件冒泡,rightnavbutton?钛
【发布时间】:2014-06-22 13:00:55
【问题描述】:

这是我的合金代码-sn-p:

    <RightNavButton>
        <Button id="btnRight" onClick="rightButtonClicked" />
    </RightNavButton>

JS:

//edit profile button
function rightButtonClicked(e) {

    Ti.API.info("testing bubble ");

    //TODO: add functionality here
    e.cancelBubble = true;
}

事件仍在冒泡。普通按钮可以正常工作。

谢谢

更新:

<RightNavButton>
            <Button id="btnRight" title='Chat' onClick="rightButtonClicked" bubbleParent='false'/>
        </RightNavButton>

仍然是泡沫。即,如果我多次单击它,它会继续打开窗口。而不是等待事件完成然后再次触发。

【问题讨论】:

    标签: javascript titanium


    【解决方案1】:

    试试

    e.stopImmediatePropagation();
    

    【讨论】:

    • 一些额外的细节/解释将有助于这个答案。
    • 是IOS还是安卓,我的应用是IOS的
    【解决方案2】:

    您应该在按钮上使用bubbleParent 属性,将其设置为false 它将起作用。这是documentation

    【讨论】:

      猜你喜欢
      • 2013-02-15
      • 1970-01-01
      • 1970-01-01
      • 2023-03-21
      • 2018-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多