无法使用jQuery Mobile 1.3.1显示Popup

时间:2013-06-30 00:52:00

标签: javascript html5 jquery-mobile mobile popup

我试图弹出一个非常简单的“你确定吗?”在jQuery Mobile中弹出。但如果我在按钮上使用data-rel="popup",则没有任何反应。如果我删除它打开的data-rel - 但是作为一个完整的窗口。逻辑运作良好,但仍然,我想看一个弹出窗口。

这是代码(简化 - 我删除了其他页面,标题,html等 - 该应用程序除了这个问题以外工作得很好,所以不需要调试那些)。要查看的两个元素是按钮“clearHistory”和弹出窗口本身“历史记录”:

<!-- history page -->
<div data-role="page" id="history">
    <div data-role="header" data-position="fixed">
        <a href="#" data-role="button" data-rel="back" data-icon="arrow-l" data-iconpos="notext">Back</a>
        <h1>History</h1>
        <a href="#deletePopup" data-role="button" data-rel="popup" id="clearHistory" data-icon="delete" data-iconpos="notext" data-theme="d">Delete</a>
    </div><!-- /header -->

    <div data-role="content">
        <ul data-role="listview" id="historyList" data-inset="true" data-theme="f"></ul>
        <h4 id="historyEmpty">History is empty</h4>
    </div><!-- /content -->

    <div data-role="footer" data-position="fixed">
        <h4><a class="ttg" href="http://www.TravelingTechGuy.com" rel="external" target="_blank">Traveling Tech Guy</a></h4>
    </div><!-- /footer -->       
</div>
<!-- end history page -->

<!-- delete history popup -->
<div data-role="popup" id="deletePopup" data-overlay-theme="a" data-theme="c" data-dismissible="false">
    <div data-role="header" data-theme="a">
        <h1>Delete History?</h1>
    </div>
    <div data-role="content" data-theme="d">
        <h3>Delete all items in history?</h3>
        <a href="#" data-role="button" data-inline="true" data-rel="back" data-theme="b">Cancel</a>
        <a href="#" data-role="button" data-inline="true" data-rel="back" data-theme="d" id="deleteHistory">Delete</a>
    </div>
</div>
<!-- delete history popup -->

知道我在这里缺少什么吗?

1 个答案:

答案 0 :(得分:1)

将弹出窗口置于<div data-role=page>内,该div应该是popup div的直接父级。我在<div data-role=content>之前放置在下面的演示中。

  

<强> Demo

对话框应放在<div data-role=page>之外,因为它们被视为页面。