简体   繁体   中英

jQuery mobile popup is not closing

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>

you can try

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM