jQuery Mobile - 标题不在第二页上呈现

时间:2012-05-01 13:50:18

标签: jquery mobile header rendering

有人可以让我摆脱苦难并告诉我为什么这不起作用?

我有一个简单的2页测试网站 - 每个页面都有一个标题和一个指向另一个页面的链接 - 所以你只需点击一个到下一个和后面等。

网站加载时一切正常 - 第1页显示了标题。单击第2页的按钮加载页面,但标题不会像第1页那样呈现。

我认为我不需要为这么简单的测试做任何特别的事情,但是不能解决什么问题。

<!DOCTYPE html> 
<html> 
<head> 
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
    <title>Mobile Test</title> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" />
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.js"></script>
    <script type="text/javascript" src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>
</head>
<body> 
    <div data-role="page" id="pg_1">
        <div data-role="header" data-position="fixed">
            <h1>Page 1</h1>
        </div>
        <div data-role="content">
            <a data-role="button" data-rel="close" href="#pg_2">Goto Page 2</a>
        </div>
    </div>
    <div data-role="page" id="pg_2">
        <div data-role="header" data-position="fixed">
            <h1>Page 2</h1>
        </div>
        <div data-role="content">
            <a data-role="button" data-rel="close" href="#pg_1">Goto Page 1</a>
        </div>
    </div>
</body>
</html>

我也尝试过使用jQuery 1.7但结果相同。

我必须做一些愚蠢的事情但却看不到它。任何帮助都会大大增加。

此致 Nymor

编辑:无法添加图片,因为我是新手,但是他们找我的第1页和第2页可以在

看到
http://i104.photobucket.com/albums/m186/Nymor/misc/jqm_t1-1.png
http://i104.photobucket.com/albums/m186/Nymor/misc/jqm_t1-2.png

1 个答案:

答案 0 :(得分:0)

您必须从链接中删除data-rel="close"

以下是解决方案:

<!DOCTYPE html> 
<html> 
<head> 
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
    <title>Mobile Test</title> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" />
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.js"></script>
    <script type="text/javascript" src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>
</head>
<body> 
    <div data-role="page" id="pg_1" data-position="fixed">
        <div data-role="header">
            <h1>Page 1</h1>
        </div>
        <div data-role="content">
            <p><a data-role="button" href="#pg_2">Goto Page 2</a></p>
        </div>
    </div>
    <div data-role="page" id="pg_2" data-position="fixed">
        <div data-role="header">
            <h1>Page 2</h1>
        </div>
        <div data-role="content">
            <p><a data-role="button" href="#pg_1">Goto Page 1</a></p>
        </div>
    </div>
</body>
</html>