【问题标题】:My button will not refresh to a new page with .live("click",function(){}); jQuery Mobile我的按钮不会使用 .live("click",function(){}); 刷新到新页面; jQuery 移动
【发布时间】:2012-09-26 16:03:32
【问题描述】:

如果我单击或 vclick 我的按钮锚标记。该页面不会加载新页面。这是我的代码。我正在使用最新版本的 Jquery mobile。这个问题是我今天开始的。

代码:

 $("a[href=#Page1").live("click",function()
 {
       updateList();
      //Will show a list and I called $("#list").listview("refresh");
 }

HTML:

有链接的页面:

  <div data-role="page" id="Page2">
      <div data-role="header">
       <h3> Header </h3>
       </div>
    <div data-role="content">
       <a role="button" href="#Page1"></a>
    </div>
</div>

页面转换到:

<div data-role="page" id="Page1">
    <div data-role="header">
       <h3> Header </h3>
    </div>
    <div data-role="content">
       <ul data-role="listview" id="list" data-filter="true" data-filter-theme="true">
       </ul>
    </div>
</div>

【问题讨论】:

  • 你缺少一些代码...
  • 我真的希望有更多的代码......
  • 发布完整的代码行真的很有帮助,也许上面和下面的行作为上下文。但至少是完整的行,所以我们可以看到匿名函数体。
  • 您使用的是什么版本的 jQuery?在 1.7 中,.live 已被弃用,取而代之的是 .on。
  • 版本 1.2.0 RC2 用于 jQuery Mobile 和 1.8.0 用于 jQuery

标签: jquery jquery-mobile


【解决方案1】:

我不确定你想要做什么,但这里有一些工作代码:(你错过了 ] 结束标签)

 $("a[href=#Page1]").live("click",function()
 {
       updateList();
      //Will show a list and I called listview.refresh();
 }

HTML:

<a href="#Page1">Link</a>
[...]
<div data-role="page" id="Page1">
<div data-role="header">
  Header
</div>

</div>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-01-16
    • 1970-01-01
    • 1970-01-01
    • 2013-07-23
    • 2021-02-17
    • 1970-01-01
    • 2012-07-17
    • 2013-11-07
    相关资源
    最近更新 更多