【问题标题】:pageinit does not called, in jquery在 jquery 中没有调用 pageinit
【发布时间】:2013-11-21 12:13:47
【问题描述】:

我正在使用Remote autocomplete jQuery Mobile 示例,我已经实现了代码,它在下面

脚本在下面

   <meta name="viewport" content="width=device-width, initial-scale=1" />
  <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.css" />
  <link rel="stylesheet" href="assets/css/styles.css" />
  <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
  <script type="text/javascript" src="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.js"></script>

       <script>
        $( document ).on( "pageinit", "#myPage", function() {
                alert("MOBILE");
         });
       </script>

html代码如下

     <div data-role="page">
          <ul id="autocomplete" data-role="listview" data-inset="true" data-filter="true" data-filter-placeholder="Search Text..." data-filter-theme="d">
      </ul>

这里的问题是警报没有出现,有人可以帮我怎么做吗?

【问题讨论】:

标签: javascript jquery html ajax jquery-mobile


【解决方案1】:

首先包含 jquery 文件,然后添加您的代码,如下所示

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://jquerymobile.com/demos/1.2.1/js/jquery.mobile-1.2.1.js">
      <script>
            $(document).bind('pageinit', "#myPage", function() {
                    alert("MOBILE");
             });
           </script>

【讨论】:

  • 对不起 Rituraj 但我已经添加了只是不包括在这里因为任何人都可以专注于我的问题我已经包括以下行 code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.css" />
  • 把 ata 放在 ;
  • 在您的视图中最新的 js 名称替换为 jQuery.js 所以重点是您在代码中正确包含 js 文件它找不到 jquery 文件
  • 在哪里?我应该更换吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多