0

我正在开发一个基于 jQuery Mobile 和 Phonegap 框架的移动应用程序。我在我的应用程序中使用 jQuery Mobile 的基于 Ajax 的导航。我的意思是使用 data-role="page" 的单页模板中的所有页面。

但是我遇到了一个问题。我正在使用 jQuery mobile 的$.mobile.changePage('#xyz');方法在页面之间导航。但问题是当我点击按钮时,页面会转到其他页面,然后再次返回我点击过的页面按钮或链接。再次喜欢a->b->a该页面本身。我不知道发生了什么。我没有代码错误或代码问题。我已经transition="fade"在我的申请中给出了。我已经尝试了所有方法,包括-webkit-backface-visibility:hidden;"$.mobile.changePage.defaults.allowSamePageTransitions = true;"但没有任何效果。我无法复制或粘贴代码。我没有这样做的权限。但如果你们能提供我的帮助,那将是一件很棒的事情。

希望大家能明白我想问你什么。

这是我的编辑。

对于 Javascript

$('#secondPage').on('pageinit',function() { jQuery('#itemlist').on('tap',function(){$.mobile.changePage('#homePage',{transition:"fade"});}); });

对于 HTML

<body>
<div data-role="page" id="firstPage">
<div data-role="header" data-position="fixed" data-theme="c">
</div>
<div data-role="content" data-theme="c">
<a data-role="button" href="#" data-theme="c" data-corners="false" id="itemlist">HomePage</a>
</div>
<div data-role="footer" data-theme="c">
</div>
</div>
<!- ------------------------------------------------------------------------------- ->
<div data-role="page" id="homePage">
<div data-role="header" data-theme="c">
</div>
<div data-role="content" data-theme="c">
</div>
<div data-role="footer" data-theme="c">
</div>
</div>
</body>
4

1 回答 1

1

我认为两个连续事件相继触发存在问题:

  1. 点击事件:页面更改为#homePage

  2. 点击事件:页面变回#firstPage

尽管我在您的代码中没有看到错误,但这可能是浏览器某些意外行为的错误。需要考虑的事项:

  • 尝试href="#"从链接中删除
  • 尝试删除 javascript 并放入href="#homePage"您的链接。
  • 尝试将 JS 事件从 更改tapclickreturn false
于 2013-05-09T12:19:04.930 回答