jquery mobile 里面页面无法执行有几个可以方便的原因:
1. http://stackoverflow.com/questions/7449402/jquery-mobile-mobile-changepage-not-loading-external-js-files/7449731#7449731里面的说明,在
jQuery Mobile does not pull the whole page into the dom, it grabs the first
So any scripts in the
I generally put all the functional JavaScript for my site on the index page and then when external pages are loaded into the dom they can benefit from the already loaded scripts.
Also, you can place JavaScript code inside the
UPDATE
A good system for this is to put all of your JS into an include file and include it on each page of the site. It will be ignored if pages are brought into the DOM by AJAX, but if someone refreshes somewhere in your site, the JS will be available.
2.链接上面要加入 rel=”external”或者
3.不使用默认的jQuery.mobile.changePage( to [, options ] )方法,使用location.href来跳转到新页面
data-role="page"
以外的元素不被加载jQuery Mobile does not pull the whole page into the dom, it grabs the first
data-role="page"
element and its descendants and pulls that into the current dom.So any scripts in the
<head>
of the document will not be included.I generally put all the functional JavaScript for my site on the index page and then when external pages are loaded into the dom they can benefit from the already loaded scripts.
Also, you can place JavaScript code inside the
data-role="page"
element and it will be included when jQuery Mobile does its AJAX load of the page.UPDATE
A good system for this is to put all of your JS into an include file and include it on each page of the site. It will be ignored if pages are brought into the DOM by AJAX, but if someone refreshes somewhere in your site, the JS will be available.
2.链接上面要加入 rel=”external”或者
data-ajax="false"
来防止ajax提交3.不使用默认的jQuery.mobile.changePage( to [, options ] )方法,使用location.href来跳转到新页面