jquery-mobilejquery-mobile-popup

Can you create nested popups with JQueryMobile


I am new to JQueryMobile... I am trying get this sample code to open another popup from within an open popup using JQueryMobile and I am failing. The first link works, but the one within the popup does not. I am also open to suggestions on a better way I should be doing this.

<!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>

Update: Alright, I do not like the solution on the duplicate question, is there a different way I could go about doing this in JQueryMobile to do something similar, maybe just using pages but theming them as the popup?


Solution

  • You can open a popup within a popup is possible is Jquery mobile. Check the below one to get popup within a popup.

     <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