在jQuery Mobile中,为什么此弹出窗口没有关闭? [英] In jQuery Mobile, why doesn't this popup close?

查看:67
本文介绍了在jQuery Mobile中,为什么此弹出窗口没有关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照 http://jquerymobile.com/test/docs/pages/popup/index.html ,但是什么也没有发生(显然,我希望在这种情况下它根本不会显示):

I am calling close as per http://jquerymobile.com/test/docs/pages/popup/index.html, but nothing is happening (obviously I expect it not to show at all in this situation):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html> 
<head> 
    <title>popup</title> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
    <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
    <meta http-equiv="Content-Type" content="text/html; charset= ISO-8859-5">
    <script>
    $(document).ready(function () {
        $("#popupBasic").popup();
        $("#popupBasic").popup("open");
        $("#popupBasic").popup("close");
    });
    </script>
</head> 
<body> 

<div data-role="page">
    <div data-role="popup" id="popupBasic">
        <p>This is a completely basic popup, no options set.</p>
    </div>

</div>

</body>
</html>

推荐答案

将您的脚本放入正文中并且可以正常工作,我另外添加了一个标题

put your script into the body and it works, I added additionally a header

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
    <title>popup</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
    <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
    <meta http-equiv="Content-Type" content="text/html; charset= ISO-8859-5">
</head>
<body>

  <div data-role="page" id="myPage">
    <div data-role="content">
      <h1>Popup</h1>
      <div data-role="popup" id="popupBasic">
        <p>This is a completely basic popup, no options set.</p>
      </div>
    </div>

    <script>
      $(document).bind('pageinit', function() {
        setTimeout(function(){
          $("#popupBasic").popup();
          $("#popupBasic").popup("open");
          $("#popupBasic").popup("close");
        }, 100);
      });
    </script>
  </div>

</body>
</html>

按照此处所述使用$(document).bind('pageinit')代替$(document).ready() ,现在增加了100ms的短暂延迟.现在可以在Firefox Nightly和Chrome中使用...

use $(document).bind('pageinit') instead of $(document).ready() as described here and now added a short delay of 100ms. Works now in Firefox Nightly and Chrome...

这篇关于在jQuery Mobile中,为什么此弹出窗口没有关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆