javascript - jQueryMobile pageInit, "Can' t 找到变量?

标签 javascript jquery-mobile

我是按照jQuery Mobile官方文档的介绍看的:

Important: Use pageInit(), not $(document).ready()

但是,当我写的时候:

pageInit(function()
    alert('ahhh');
});

我的 Safari 控制台告诉我:Cant find variable "pageInit"

这是为什么?如何使用函数 pageInit()

最佳答案

$( '#aboutPage' ).live( 'pageinit',function(event){
  alert( 'haa!' );
});

或使用 JQuery 1.7

$("#myPage").on('pageinit', function(event){
    alert('haa');
});

http://api.jquery.com/on/

http://api.jquery.com/live/

顺便说一下,在 JQMobile 中它推荐使用 Jquery 1.6.4,因此,第一个例子是正确的。

ZY

关于javascript - jQueryMobile pageInit, "Can' t 找到变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8172364/

相关文章:

javascript - 循环中的异步等待在第 370 次迭代后停止

javascript - 为什么在水平方向时 window.innerHeight 返回 180 ?

javascript - 删除数组递归调用模式中的项目?

jquery - 使用 phonegap 的 pagecreate 事件加载页面时出现问题

javascript - 更改按钮的字体大小

javascript - 为什么使用 jQuery Mobile 的 css 中断箭头?

javascript - 如何根据链接内容添加类?

javascript - Javascript 正则表达式是否包含隐式 ^?

javascript - 无法在 jquery mobile 1.4.5 中重新加载页面

javascript - 动态添加的 anchor 点击不会调用jquery mobile中的函数