首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jQuery手机中单页和多页文档的混合

问jQuery手机中单页和多页文档的混合
EN

Stack Overflow用户
提问于 2013-02-14 10:36:51
回答 1查看 1.2K关注 0票数 2

我从jQuery手机开始,我遇到了一个问题。我有两个HTML文档:

  • page1.html
  • page2.html
    • page2a
    • page2b

​

问题如下:

  • 当我从page1.html浏览到page2.html时,它会显示page2a,但我不能浏览到page2b
  • 当我从page1.html浏览到page2a时,它停留在page1.html上。
  • 当我从page2.html浏览到page2a或page2b时,效果很好

我的解决方案有什么问题?有什么好的解决办法让它正常工作吗?

以下是供参考的代码:

Page1.html

代码语言:javascript
复制
<!DOCTYPE html> 
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <title>Page 1</title> 
  <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0-rc.1/jquery.mobile-1.3.0-rc.1.min.css" />
  <script src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
  <script src="http://code.jquery.com/mobile/1.3.0-rc.1/jquery.mobile-1.3.0-rc.1.min.js"></script>
</head> 

<body> 

<div data-role="page">
  <div data-role="header">
    <h1>Single page</h1>
  </div>
  <div data-role="content">  
    <p>See <a href="page2.html">page 2</a>.</p>
    <!-- <p>See <a href="page2.html#a">page 2a</a>.</p> -->
  </div>
</div>

</body>
</html>

Page2.html:

代码语言:javascript
复制
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <title>Page 2</title> 
  <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0-rc.1/jquery.mobile-1.3.0-rc.1.min.css" />
  <script src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
  <script src="http://code.jquery.com/mobile/1.3.0-rc.1/jquery.mobile-1.3.0-rc.1.min.js"></script>
</head> 

<body> 

<!-- Start of first page: #a -->
<div data-role="page" id="a">
  <div data-role="header">
    <h1>Page 2a</h1>
  </div>
  <div data-role="content" >  
    <p><a href="#b" data-role="button" data-transition="slide">Show page "2b"</a></p>
  </div>
</div>

<!-- Start of second page: #b -->
<div data-role="page" id="b">
  <div data-role="header">
    <h1>Page 2b</h1>
  </div>
  <div data-role="content">  
    <p><a href="#a" data-direction="reverse" data-transition="slide" data-role="button">Back to page "2a"</a></p>  
  </div>
</div><!-- /page b -->

</body>
</html>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-02-14 11:02:52

检查下面的问题。它似乎只适用于data-rel="external"。

JQM多页

更新:

注意:您不能链接到具有Ajax导航活动的多页文档,因为框架只加载它找到的第一个页面,而不是完整的内部页面集。在这些情况下,您必须在没有Ajax的情况下链接(请参阅下一节)以进行完整的页面刷新,以避免潜在的哈希冲突。目前有一个https://github.com/ToddThomson/jQuery-Mobile-Subpage-Widget可以在多页文档中加载。

来源:JQM链接页

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14872857

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档