jquery - 动态更改 jQuery Mobile ListView 中的图标

标签 jquery listview jquery-mobile icons

当我动态更改图标时,它不会反射(reflect)页面上的更改,即使在标记中已更改。

示例:

      <ul data-role="listview" data-autodividers="true" data-filter="true" data-inset="true">
        <li data-icon="check"><a href="#">Adam Kinkaid</a></li>
        <li data-icon="check"><a href="#">Alex Wickerham</a></li>
        <li data-icon="check"><a href="#">Avery Johnson</a></li>
        <li data-icon="check"><a href="#">Bob Cabot</a></li>
        <li data-icon="check"><a href="#">Caleb Booth</a></li>
        <li data-icon="check"><a href="#">Christopher Adams</a></li>
        <li data-icon="check"><a href="#">Culver James</a></li>
    </ul>

$("li").tap(function() {
    //Alert the old icon
    alert($(this).jqmData("icon"));

    //Toggle
    $(this).jqmData("icon") == "false" ? $(this).jqmData("icon", "check") :             $(this).jqmData("icon", "false");

    //Alert the new icon
    alert($(this).jqmData("icon"));
});

http://jsfiddle.net/Mc97V/

最佳答案

我给你做了一个工作示例:http://jsfiddle.net/Gajotres/qgE6L/

$('#index').live('pagebeforeshow',function(e,data){    
    $("li").tap(function() {
        $(this).buttonMarkup({ icon: "edit" });
    });  
});

关于jquery - 动态更改 jQuery Mobile ListView 中的图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15115219/

相关文章:

javascript - 如何映射每个元素及其子元素

javascript - 如何使用jquery和greasemonkey在谷歌分析中选择一个选项?

javascript - 如何使用 jQuery 将事件附加到动态 HTML 元素?

listview - jQuery Mobile ListView 数据拆分将右键更改为文本

android - 用于 ListView 的自定义适配器内的动画按钮

javascript - 在 jQuery Mobile 1.4.2 中获取加载的页面

javascript - Wordpress 定制器自定义控件传输 postMessage 不起作用

Android:从不同的 Activity 刷新 ListView

html - 通过 html 调用 GPS 应用程序

css - 如何在 jQuery Mobile 输入中添加 bootstrap 之类的前缀?