jQueryMobile脚本在每个页面加载上运行两次 [英] jQueryMobile script runs twice on each pageload

查看:72
本文介绍了jQueryMobile脚本在每个页面加载上运行两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试获取一个脚本,该脚本在文章的第一和第二段之后插入一个div文本,以在jQueryMobile中工作.它在第一个页面加载时起作用,但是在第二个页面加载时,它加载内容两次,第三次页面加载时,等等,依此类推.

I've been trying to get a script that inserts a div of text after the first and second paragraph of an article to work in jQueryMobile. It works on the first pageload, but on the second it loads the content twice, and the third time it's loaded three times, and so on.

jQueryMobile库和我的脚本被加载到头部:

The jQueryMobile libraries and my script is loaded in the head:

<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="myscript.js">
<script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />

那我有

<body id="mobile">
<div id="wrapper" data-role="page">

然后是页面的内容

我的脚本按照已记录执行.在jquerymobile.com上

My script is executed as documented on jquerymobile.com

$("#wrapper").live('pageinit', function() {

我错过了什么吗?任何帮助将不胜感激.

Am I missing something? Any help will be deeply appreciated.

推荐答案

尝试添加data-dom-cache ="false",它应该看起来像这样

try adding data-dom-cache="false" it should look like this

<body id="mobile">
<div id="wrapper" data-role="page" data-dom-cache="false">

这篇关于jQueryMobile脚本在每个页面加载上运行两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆