Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 显示jquery mobile对话框时如何自定义?_Javascript_Jquery_Html_Jquery Mobile - Fatal编程技术网

Javascript 显示jquery mobile对话框时如何自定义?

Javascript 显示jquery mobile对话框时如何自定义?,javascript,jquery,html,jquery-mobile,Javascript,Jquery,Html,Jquery Mobile,我需要能够选择何时打开jquery对话框,但我似乎什么都不做 到目前为止我已经试过了 <html> <head> <meta charset="UTF-8"> <title>Document</title> <!-- Include meta tag to ensure proper rendering and touch zooming --> <meta name="viewpor

我需要能够选择何时打开jquery对话框,但我似乎什么都不做

到目前为止我已经试过了

<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>

    <!-- Include meta tag to ensure proper rendering and touch zooming -->
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Include jQuery Mobile stylesheets -->
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">

    <!-- Include the jQuery library -->
    <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>

    <!-- Include the jQuery Mobile library -->
    <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>

</head>
<body>
        <div data-role="main" class="ui-content">

            <a href="#myPopupDialog" data-rel="popup" data-role="dialog" data-position-to="window" data-transition="fade" class="ui-btn ui-corner-all ui-shadow ui-btn-inline">Open Dialog Popup</a>

            <a href="#" onclick="test()">Test</a>

            <div data-role="popup" id="myPopupDialog">

                <div data-role="header">
                    <h1>But wait theres more!</h1>
                </div>

                <div data-role="main" class="ui-content">
                    <h2 style="text-align: center;">Would you like an exclusive offer?</h2>
                    <a href="#" class="ui-btn ui-corner-all" data-rel="back">Sounds Good!</a>
                    <a href="#" class="ui-btn ui-corner-all ui-icon-back" data-rel="back" data-theme="a">No Thanks, Take me back..</a>
                </div>

                <div data-role="footer">
                    <h1>Footer Text</h1>
                </div>

            </div>
        </div>

<script>

    $(document).ready(function(){

        console.log(document.body.scrollTop);

        if(document.body.scrollTop === 0)
        {
            $.mobile.changePage('#myPopupDialog', 'pop', true, true);
        }

    });

</script>
</body>
</html>
这是可行的,但当我在javascript中更改if语句时,如果我删除顶部的锚标记,它也会中断,只是不会显示。。。jquerymobile把我弄糊涂了

所以不管怎样,我的问题是如何手动在页面上显示对话框,我希望它显示在同一页面上,而不是另一页面上。

使用以下方法:

$("#myPopupDialog").addClass("ui-page-active ui-page ui-page-theme-a")

抱歉,如果缺少任何内容,请留下评论,询问您需要什么,我将提供$myPopupDialog.popupopen而不是$mobile.changePage'myPopupDialog'。。。。对话框和弹出窗口不一样。请参考jQM文档。请使用更多信息进行编辑。不鼓励只编写代码并尝试此答案,因为它们不包含可搜索的内容,也不解释为什么有人应该尝试此选项。无论哪种方式,这对我都不起作用,我找到了解决方案,并将在有时间时添加我的解决方案