-1

如何设置 Jquery Mobile 和 Phonegap?$(document).ready 不起作用。

4

2 回答 2

0

当您将 Jquery Mobile 与 Phonegap 一起使用时,基本的 javascript 很难启动。下面你可以看到如何设置一个简单的 hello world。

代码:http: //jsfiddle.net/zwTQ4/

<div data-role="header">
    <h1>My Title</h1>
</div><!-- /header -->

<div data-role="content">    
    <p>Hello world</p>        
</div><!-- /content -->

<script type="text/javascript">
    $("#indexPage").bind(
         'pageinit',function() {
               alert("Hello world");
             });
</script>

于 2012-10-23T06:42:23.553 回答
0

我建议阅读 jquerymobile 的文档,关于 events 的部分

那里的第一个通知之一是:

Important: Use $(document).bind('pageinit'), not $(document).ready()
于 2012-10-23T07:58:39.237 回答