Ajax jquerymobile";pageinit";短时间调用hashtag

Ajax jquerymobile";pageinit";短时间调用hashtag,ajax,jquery-mobile,page-init,Ajax,Jquery Mobile,Page Init,我目前正在使用jQuery mobile构建一个页面。 我需要在一个页面上加载一些custonjavascript,所以我找到了这个函数。 下面是我正在使用的一个简短示例: page1.html: <!doctype html> <meta charset="uft-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>page1 | test

我目前正在使用jQuery mobile构建一个页面。 我需要在一个页面上加载一些custonjavascript,所以我找到了这个函数。 下面是我正在使用的一个简短示例:

page1.html:

<!doctype html>
<meta charset="uft-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>page1 | test page for jquery mobile</title>

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css">

<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script>
<script src="js.js"></script>

<div data-role="page" id="page1">
    <div data-role="header">
        <h1>Page 1 Title</h1>
    </div>

    <div data-role="content">
        <a href="page2.html">go to page2</a>
        <p>Page 1 content goes here.</p>
    </div>

    <div data-role="footer">
        <h4>Page 1 Footer</h4>
    </div>
</div>
当我点击page1.html上的链接时(可能只有几毫秒),然后它重定向到

example.org/page2.html
我想是因为身份证的缘故。。但是我需要这个用于pageInit(据我所知)。 这种行为正常吗?还是我做错了什么。甚至可能有一个命令不调用哈希标记。

给你:

需要注意的是,如果要从通过AJAX加载的移动页面链接到包含多个内部页面的页面,则需要在链接中添加rel=“external”或data AJAX=“false”。这告诉框架重新加载整个页面以清除URL中的AJAX哈希。这一点非常关键,因为AJAX页面使用散列(#)来跟踪AJAX历史,而多个内部页面使用散列来指示内部页面,因此这两种模式之间的散列会发生冲突

例如,指向包含多个内部页面的页面的链接 像这样:

多页链接


Src:

谢谢,但实际上,通过Ajax加载页面是很好的。我之所以使用id,是因为JavaScript的pageInit。但是我不想重新加载整个页面。我相信你需要在URL中添加#标记,这样经验丰富的行为是正常的。“AJAX页面使用散列(#)来跟踪AJAX历史记录。”如果您没有将rel=“external”或data AJAX=“false”添加到URL,那么您使用的是带有#标记的AJAX导航系统。
$(document).delegate('#page2', 'pageinit', function() {
    $('<div />', {
        html: 'Some text that was added via jQuery'
    }).appendTo('#addstuff');
});
example.org/page1.html#/page2.html
example.org/page2.html