这是我的js ratings.js:
$(document).ready(function(){ $("#rating_1").click(function () { $("#rating_2").css('backgroundPosition','0px 0px'); $(this).css('backgroundPosition','-45px 0px'); }); });
当我加载index.PHP然后转到article.PHP时,我的触发器都没有给ratings.js工作.
如果我添加rel =“external”或data-ajax =“false”我的触发器工作.
然而,我失去了装载轮出现的能力.
有什么建议?
谢谢!
解决方法
Important: Use
$(document).bind('pageinit')
,not$(document).ready()
The first thing you learn in jQuery is to call code inside the
$(document).ready()
function so everything will execute as soon as
the DOM is loaded. However,in jQuery Mobile,Ajax is used to load the
contents of each page into the DOM as you navigate,and the DOM ready
handler only executes for the first page. To execute code whenever a
new page is loaded and created,you can bind to the pageinit event.
This event is explained in detail at the bottom of this page.
> http://jquerymobile.com/demos/1.1.0/docs/api/events.html
尝试:
$(document).bind('pageinit',function() { $("#rating_1").click(function() { $("#rating_2").css('backgroundPosition','-45px 0px'); }); });
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。