简体   繁体   English

jQuery Mobile链表pageInit(),而不是$(document).ready()

[英]jQuery Mobile linked list pageInit(), not $(document).ready()

I'm trying to make a mobile version of a web page. 我正在尝试制作网页的移动版本。 My problem is that I have to manipulate a accordion menu to use jQuery mobile linked list. 我的问题是我必须操纵手风琴菜单才能使用jQuery移动链表。 To do this I manipulate the menu with jQuery ex: 为此,我使用jQuery ex操作菜单:

$(document).ready(function() {
    $('#globalMenu').attr("data-role", "listview");
    .. .. . . ..
});

It works great if I load the page first time, but when I navigate in the jQuery mobile list and push one of the link the script do not run, but if I refresh the page ( f5 ) it works! 如果我第一次加载页面,效果很好,但是当我在jQuery移动列表中导航并按下链接之一时,脚本不会运行,但是如果刷新页面( f5 ),它将起作用! I've read that I have to use init instead of document ready but I can't manage it to work. 我读过我必须使用init而不是准备好文档,但是我无法管理它。

Please write some examples. 请写一些例子。

jQueryMobile event page jQueryMobile事件页面

Supposing your page div is like this: 假设您的页面div是这样的:

<div id="my-page" data-role="page">

Try with: 尝试:

$('#my-page').live('pageinit', function(event){
  $('#globalMenu').attr("data-role", "listview");
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM