- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
大家好。
我想更多地了解 jQuery mobile,所以我昨天就开始了,但我已经陷入了困境。
我想要实现的是:
这样,pages/home.html 将成为默认页面。这有可能吗?目前,我有这个:
<body>
<script>
$(document).bind('pagecreate', function()
{
$.mobile.changePage("pages/home.html");
});
</script>
</body>
</html>
它显示出一种奇怪的行为,滑动两次并显示错误消息(表示页面无法加载)。
我希望所有页面都位于页面子目录中。这是可能的还是我又不可能了?
谢谢。
编辑
其他页面正文中包含以下内容;
<div data-role="page">
<div data-role="header">
<h1>Page Title</h1>
</div>
<div data-role="content">
<p>Page content goes here.</p>
</div>
</div>
最佳答案
有可能,由于将事件绑定(bind)到文档而发生奇怪的行为,每次加载页面时都会触发 pagecreate 事件。 (第一次是从index到pages/home.html,第二次是从pages/home.html到pages/home.html)为了避免这个问题,请在索引页中设置一个 ID,如下所示,并将事件绑定(bind)到 #indexPage 而不是文档。
<div data-role="page" id="indexPage">
<script type="text/javascript">
$("#indexPage").bind('pagecreate', function()
{
$.mobile.changePage("pages/home.html");
});
</script>
请注意,$.mobile.changePage() 仅当您的 html 放置到托管/本地服务器(localhost)时才有效。如果您不想将文件放到服务器上。还有一种替代方法,使用 window.location 而不是 $.mobile.changePage()。因为 $.mobile.changePage() 会通过使用 ajax 加载 html 以编程方式从一个页面更改到另一个页面,而不是在浏览器中刷新整个页面。
<script type="text/javascript">
$("#indexPage").bind('pagecreate', function()
{
window.location = "pages/home.html;
});
</script>
更详细的步骤请引用http://demanstudio.blogspot.com/2013/02/change-pages-in-jquery-mobile.html
希望这可以帮助你。
关于jQuery Mobile 在 PageCreate 上更改页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15040853/
我正在尝试复制此代码:http://jsfiddle.net/ezanker/5qe6g/1/ 我正在使用 goolge blogger 我已经在模板 html 中导入了
我有一个两页的应用程序。这两个页面都有在客户端动态创建的所有内容。 问题是,如果我转到页面 A > 页面 B > 页面 A > 页面 B,在第二次访问后,页面 B 不再通过 Jquery Mobile
我有 5 页 - 为了方便起见,我们可以这样说: one.html 两个.html 三.html 四.html 五.html 当我加载每个单独的页面时,pageinit 和 pagecreate 都正
大家好。 我想更多地了解 jQuery mobile,所以我昨天就开始了,但我已经陷入了困境。 我想要实现的是: 加载index.html index.html 重定向到pages/home.html
提前感谢您查看此 jQuery Mobile(版本 1.1.0)问题。 我的第一个问题是:您使用什么函数在每个页面加载和每个 ajax 页面调用上运行(它们似乎是两个独立的野兽)?我希望它们每次都运行
我正在将外部页面加载到 jqm 页面上的 div 中,为了使用 jQuery 移动样式对其进行增强,我在 div 上调用了 trigge('pagecreate'),这可以从控制台进行。 $('#s
我有一个 JQuery Mobile 应用程序。在应用程序的第一页上,我尝试在加载时设置一些字段值(如果之前已设置)。为了尝试做到这一点,我目前有以下内容: 索引.html
我正在开发我的第一个 jQuery Mobile 项目,但遇到了障碍。我使用的是 1.0 版本,到目前为止,该项目非常简单,三页,仅在索引上包含脚本。我一开始错误地使用了 $(document).re
在我的应用程序“index.page”中,我在标签内加载了 phonegap 和 jqm 脚本。我的索引页中有一个链接,如下所示 Click here 如果我在我的索引页面中单击上面的 u
我在我的项目中使用 jQuery Mobile,我遇到了这个问题。 Uncaught TypeError: Cannot read property 'options' of undefined 如果
使用 2 个简单页面和 jQuery Mobile。 尝试在页面的每次加载时执行一些js。例如,第一页显示警报(1),第二页显示警报(2)。当第一次在浏览器中加载页面(或刷新 F5)时,它的行为符合预
在 jQuery Mobile 中创建页面时,我需要选择第一个 TAB 作为默认值。 用官方的例子不清楚怎么做。 http://demos.jquerymobile.com/1.4.2/tabs/ 有
我之前尝试过发布这个问题,但当时没有意识到我遇到的问题来自于使用 jQuery 1.3.0 库。 我正在尝试使用 jQuery Mobile 在页面上创建一个无需用户交互的对话框。它在 FireFox
我是一名优秀的程序员,十分优秀!