【问题标题】:jQuery mobile collapsible button in header, stop collapse/expand标题中的 jQuery 移动可折叠按钮,停止折叠/展开
【发布时间】:2014-08-23 21:39:09
【问题描述】:

我想在 jQuery 可折叠的标题中放置一个按钮。

当然,当我这样做时,按下按钮也会使可折叠展开/折叠。我发现解决方案是

e.stopPropagation();
e.stopImmediatePropagation();    

我从这里拿的:adding the button to the collapsible set and getting the value of the collapsible element

但是有一个问题。当可折叠项位于已加载的页面上时:

$.mobile.changePage("#second", {transition : "pop", role : "page"});

然后,使用stopPropagation 立即导致 jquery-mobile 切换到原始页面(例如索引页面)。

这是一个示例(来自上面链接中提供的 jsfiddle),它演示了我遇到的问题:http://jsfiddle.net/ga5f86mm/1/

所以重申一下,我希望能够在 jquery-mobile 可折叠的标题中放置一个按钮,而不会导致它在单击该按钮时折叠/展开。

【问题讨论】:

    标签: javascript jquery jquery-mobile


    【解决方案1】:

    首先,我很抱歉;我不是要更新你的 Fiddle,我是想分叉它,但是我做了更新它......

    无论如何,添加:

    e.preventDefault();
    

    http://jsfiddle.net/ga5f86mm/2/

    【讨论】:

    • 更新小提琴会将其保存为新版本(因此 URL 末尾的 2 而不是 1)。没必要为此感到难过:)
    猜你喜欢
    • 1970-01-01
    • 2012-01-14
    • 2018-12-13
    • 1970-01-01
    • 2016-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-19
    相关资源
    最近更新 更多