Framework7 - 模态框嵌套



描述

你可以在一个模态框内使用另一个模态框。

示例

以下示例演示了在 Framework7 中嵌套模态框的使用,它在一个模态框内提供另一个模态框:

<!DOCTYPE html>
<html>

   <head>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1, 
         maximum-scale = 1, minimum-scale = 1, user-scalable = no, minimal-ui" />
      <meta name = "apple-mobile-web-app-capable" content = "yes" />
      <meta name = "apple-mobile-web-app-status-bar-style" content = "black" />
      <title>Nesting Modals</title>
      <link rel = "stylesheet" 
         href = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/css/framework7.ios.min.css" />
      <link rel = "stylesheet" 
         href = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/css/framework7.ios.colors.min.css" />
   </head>

   <body>
      <div class = "views">
         <div class = "view view-main">
         
            <div class = "navbar">
               <div class = "navbar-inner">
                  <div class = "center sliding">Nesting Modals</div>
               </div>
            </div>
            
            <div class = "pages">
               <div data-page = "index" class = "page navbar-fixed">
                  <div class = "page-content">
                     <div class = "content-block">
                        <p><a href = "#" class = "nesting_modal">Enter your name:</a></p>
                     </div>
                  </div>
               </div>
            </div>
            
         </div>
      </div>
      
      <script type = "text/javascript" 
         src = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/js/framework7.min.js"></script>
      
      <script>
         // Here you can initialize the app
         var myApp = new Framework7();

         // If your using custom DOM library, then save it to $$ variable
         var $$ = Dom7;

         // Add the view
         var mainView = myApp.addView('.view-main', {
            // enable the dynamic navbar for this view:
            dynamicNavbar: true
         });

         $$('.nesting_modal').on('click', function () {
            myApp.prompt('Enter your name?', function (value) {
               myApp.confirm('Hey...your name is : ' + value + '', function () {
                  myApp.alert('This is your name : "' + value + '"!!!');
               });
            });
         });
      </script>
   </body>

</html>

输出

让我们执行以下步骤来查看上面给出的代码是如何工作的:

  • 将上面给出的 HTML 代码保存为 **modal_nesting.html** 文件到您的服务器根目录。

  • 打开此 HTML 文件,地址为 https://127.0.0.1/modal_nesting.html,输出结果如下所示。

  • 当您点击“输入您的姓名”选项时,您将得到一个弹出式向导,它执行一个函数并显示输入的文本。输入文本并点击“确定”后,再次点击“确定”时会执行另一个函数。

framework7_overlays.htm
广告