【问题标题】:Can you create nested popups with JQueryMobile您可以使用 JQueryMobile 创建嵌套弹出窗口吗
【发布时间】:2014-04-29 15:10:50
【问题描述】:

我是 JQueryMobile 的新手...我正在尝试获取此示例代码以使用 JQueryMobile 从打开的弹出窗口中打开另一个弹出窗口,但我失败了。第一个链接有效,但弹出窗口中的链接无效。我也愿意接受有关我应该这样做的更好方式的建议。

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="jquery/mobile/jquery.mobile-1.4.2.css" />
<script type="text/javascript" src="jquery/jquery-2.0.3.js" ></script>
<script type="text/javascript" src="jquery/mobile/jquery.mobile-1.4.2.js" ></script>    
<style>
    html, body { padding: 0; margin: 0; }
    html, .ui-mobile, .ui-mobile body {
        height: 585px;
    }
    .ui-mobile, .ui-mobile .ui-page {
        min-height: 585px;
    }   
</style>
</head>
<body>
<div data-role="page" style="max-height:590px; min-height:590px;">
    <a href="#mainMenu" data-rel="popup" data-role="button" data-inline="true" data-transition="pop">main menu</a>              

    <div data-role="popup" id="mainMenu" data-overlay-theme="a" data-theme="a" style="max-width:400px;" class="ui-corner-all">
        <div data-role="header" data-theme="a" class="ui-corner-top">
            <h1>Delete Page?</h1>
        </div>
        <div role="main" class="ui-corner-bottom ui-content">
            <h3 class="ui-title">Are you sure you want to delete this page?</h3>
            <p>This action cannot be undone.</p>
            <a href="#settingsMenu" data-rel="popup" data-position-to="window" data-role="button" data-inline="true" data-transition="pop">settings</a>             
            <div data-role="popup" id="settingsMenu" data-overlay-theme="a" data-theme="a" style="max-width:400px;" class="ui-corner-all">
            <div data-role="header" data-theme="a" class="ui-corner-top">
                <h1>Delete Page?</h1>
                </div>
            <div role="main" class="ui-corner-bottom ui-content">
                <h3 class="ui-title">Are you sure you want to delete this page?</h3>
                <p>This action cannot be undone.</p>

                <a href="#" data-role="button" data-inline="true" data-rel="back" data-theme="a">Cancel</a>
                <a href="#" data-role="button" data-inline="true" data-rel="back" data-transition="flow" data-theme="b">Delete</a>
            </div>                
            <a href="#" data-role="button" data-inline="true" data-rel="back" data-theme="a">Cancel</a>
            <a href="#" data-role="button" data-inline="true" data-rel="back" data-transition="flow" data-theme="b">Delete</a>
        </div>
    </div>        
 </div>
 </body>
 </html>

更新: 好吧,我不喜欢重复问题的解决方案,有没有其他方法可以在 JQueryMobile 中做类似的事情,也许只是使用页面但将它们主题化为弹出窗口?

【问题讨论】:

标签: jquery-mobile jquery-mobile-popup


【解决方案1】:

您可以在弹出窗口中打开一个弹出窗口,可以是 Jquery mobile。检查以下一项以在弹出窗口中弹出窗口。

 <a href="#expensePopup" data-rel="popup" data-role="button" data-inline="true" id="addExpenses1">Open poup 1</a>

<div data-role="popup" id="expensePopup"  data-dismissible="false"> <a href="#" data-rel="back" data-role="button" data-theme="a" data-icon="delete" data-iconpos="notext" class="ui-btn-left">Close</a>
<div>  <div data-role="header">
    <h3>popup1</h3>
  </div>
              <a href="#pagetwo" data-rel="popup" data-role="button" data-icon="plus"  id="deleteExpenses1">Open popup 2</a>

</div>
<div   id="pagetwo" data-role="popup">
    <a data-role="button" data-theme="a" data-icon="delete"  class="ui-btn-left"  data-iconpos="notext" onclick="closePopup();"></a>
  <div data-role="header">
    <h3>I'm A popup2!</h3>
  </div>

  <div data-role="main" class="ui-content">
    <p>The dialog box is different from a normal page.</p>
  </div>


</div> 
    <div>
function closePopup(){
 $("#pagetwo").popup("close");
 $("#expensePopup").popup("open");
}

See this fiddle Demo

【讨论】:

  • 虽然答案已被接受,但我很好奇这是“弹出窗口中的弹出窗口”。第一个不会保持打开状态。
  • @Aravin 当popup1可见时,点击“打开popup2”会使popup1消失,需要调用$("#expensePopup").popup("open");为了让 popup1 重新出现。这不是我所说的“弹出窗口中的弹出窗口”,因为它重新创建了 popup1
  • @DaveNottage 检查此文档stackoverflow.com/questions/23189886/…
  • @Aravin 我知道文档;在您的回答中,您声明:“您可以在弹出窗口中打开一个弹出窗口是可能的 Jquery mobile。检查以下内容以在弹出窗口中获取弹出窗口。”根据您自己的参考,您表明此陈述不正确
  • @DaveNottage 我回答了他的问题,而不是您的期望。对不起那个词(很遗憾对你没有帮助)。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-07
  • 2017-01-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多