jQuery mobile popup is not closing

。_饼干妹妹 提交于 2019-12-11 15:03:44

问题


sorry for not supplying a fiddle, I can't get it set up there.

However, I use the following code to programatically open and close a popup. Only that it doesn't close and stays open. What am I doing wrong?

<!DOCTYPE html> 
<html> 
<head> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.js"></script>

    <script>
    $(document).ready(function()
    {
        $("#initialpopup").popup("open");

        setTimeout(function()
        {
            $("#initialpopup").popup("close");
        }, 500);    

    });
    </script>
</head>
<body>

    <div data-role="page" data-theme="a" data-content-theme="c">

        <div data-role="popup" id="initialpopup" data-overlay-theme="a" data-theme="a">Foobar</div>


    </div>

</body>
</html>

回答1:


you can try

$('#initialpopup').popup('open', {transition: 'pop'});
window.setTimeout('$("#initialpopup").popup("close");', 500);


来源:https://stackoverflow.com/questions/15206455/jquery-mobile-popup-is-not-closing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!