打开jQuery Mobile对话框,其中包含指向不同文件中特定jQuery Mobile页面的链接

时间:2013-03-28 19:39:31

标签: jquery html5 css3 jquery-mobile dialog

我有两个文件 - index.html和c.html。

当我输入

<a data-rel="dialog" data-transition="flip" href="c.html">button</a>
在index.html中,它可以正常显示c.html作为对话框。但是使用

<a data-rel="dialog" data-transition="flip" href="c.html#0">button</a>

根本不起作用(我希望它在c.html中显示id =&#34; 0&#34;页面)。如何使它工作?

1 个答案:

答案 0 :(得分:6)

这不可能。

jQuery Mobile不支持将查询参数传递到内部/嵌入页面,但有两个插件可以添加到项目中以支持此功能。有一个轻量级页面params plugin和一个功能更全面的jQuery Mobile router plugin,用于backbone.js或spine.js。一个名为routerlite的新插件只用四种方法就可以实现简单:routeinit,routechange,pageinit和pagechange。

官方文件:http://jquerymobile.com/demos/1.2.0/docs/pages/page-navmodel.html

证明:

<强>的index.html

<!DOCTYPE html>
<html>
<head>
    <title>jQM Complex Demo</title>
    <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi"/>
    <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>    
</head>
<body>
    <div data-role="page" id="index">
        <div data-theme="a" data-role="header">
            <h3>
                First Page
            </h3>
            <a href="index3.html#second" class="ui-btn-right">Next</a>
        </div>

        <div data-role="content">

        </div>

        <div data-theme="a" data-role="footer" data-position="fixed">

        </div>
    </div>  
</body>
</html>   

<强> index3.html

<!DOCTYPE html>
<html>
<head>
    <title>jQM Complex Demo</title>
    <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi"/>
    <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>    
</head>
<body>
    <div data-role="page" id="third">
        <div data-theme="a" data-role="header">
            <h3>
                Third Page
            </h3>
            <a href="#second" class="ui-btn-right">Next</a>
        </div>

        <div data-role="content">

        </div>

        <div data-theme="a" data-role="footer" data-position="fixed">

        </div>
    </div> 
    <div data-role="page" id="second">
        <div data-theme="a" data-role="header">
            <h3>
                Second Page
            </h3>
            <a href="#index" class="ui-btn-left">Back</a>
        </div>

        <div data-role="content">

        </div>

        <div data-theme="a" data-role="footer" data-position="fixed">

        </div>
    </div>    
</body>
</html>