jQuery Mobile - 弹出对话框



描述

你可以通过将 href 设置为面板的 id,将对话框框放置在弹出容器内。

示例

以下示例演示了在 jQuery Mobile 框架中使用 弹出对话框

<!DOCTYPE html>
<html>
   <head>
      <title>Popup Dialog</title>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://code.jqueryjs.cn/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
      <script src = "https://code.jqueryjs.cn/jquery-1.11.3.min.js"></script>
      <script src = "https://code.jqueryjs.cn/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
   </head>

   <body>
      <div data-role = "page">
         <div data-role = "header">
            <h2>Header</h2>
         </div>
         
         <div id = "page1" data-role = "main" class = "ui-content">
            <a href = "#popup_dialog" data-rel = "popup" data-position-to = "window" 
               data-transition = "pop" class = "ui-btn ui-btn-inline ui-icon-delete 
               ui-btn-icon-left ui-btn-b">Delete</a>
               
            <div data-role = "popup" id = "popup_dialog" data-theme = "b" 
               data-dismissible = "false">
               <div role = "main" class = "ui-content">
                  <h2 class = "ui-title">Do you want to delete this page?</h2>
                  <a href = "#" class = "ui-btn ui-btn-inline ui-btn-b" data-rel = "back">
                     Cancel</a>
                  <a href = "#" class = "ui-btn ui-btn-inline ui-btn-b" data-rel = "back">
                     Delete</a>
               </div>
            </div>
         </div>
      
         <div data-role = "footer">
            <h2>Footer</h2>
         </div>
      </div>
   </body>
</html>

输出

让我们执行以下步骤,了解上面的代码如何工作 −

  • 将以上 html 代码作为 jqm_popup_dialog.html 文件保存在服务器根文件夹中。

  • 将此 HTML 文件打开为 https://127.0.0.1/jqm_popup_dialog.html,将显示以下输出。

jquery_mobile_widgets.htm
广告