1

検索フィルターを備えたリストビューがあり、ほぼ 300<li>です。

リストビューの更新には約 7 秒かかりますが、単一のデータ アイコンを更新したい場合があります<li>

完全なリストビューを更新せずに単一のものを更新する方法はあり<li>ますか?

編集:

<ul data-role="listview" id="myList">
    <li id="a" data-icon="check"><a href="">A</a></li>
    <li id="b" data-icon="check"><a href="">B</a></li>
</ul>

解決策:

$('#a span').removeClass ('ui-icon-check');
$('#a span').addClass ('ui-icon-refresh');
4

1 に答える 1

1

このようなものは機能しますか?

JS

// US Flag
var newImageSource = "http://jquerymobile.com/demos/1.2.0/docs/lists/images/us.png"; 

// this is the item you want to change
var listItemChildNeeded = 3; 

// this is the list with the found item
var listItemChildSelected = $("#myList :nth-child("+listItemChildNeeded+")"); 

// digging into the jQM markup first level
var listItemChildSelectedFirstChild = listItemChildSelected.children(); 

// digging into the jQM markup second level
var listItemChildSelectedSecondChild = listItemChildSelectedFirstChild.children(); 

// digging into the jQM markup third level
var listItemChildSelectedThirdChild = listItemChildSelectedSecondChild.children(); 

// digging into the jQM markup fourth level
var listItemChildSelectedFourthChild = listItemChildSelectedThirdChild.children(); 

// Change Great Britains Flag to the US Flag
listItemChildSelectedFourthChild.attr('src', newImageSource);


// one liner syntax
//$("#myList :nth-child(3)").children().children().children().children().attr("src","http://jquerymobile.com/demos/1.2.0/docs/lists/images/us.png");


​

HTML

<div data-role="page" id="home" class="pages" data-theme="c">
    <ul data-role="listview" id="myList">
        <li><a href="#"><img src="http://jquerymobile.com/demos/1.2.0/docs/lists/images/gf.png" alt="France" class="ui-li-icon">France <span class="ui-li-count">4</span></a></li>
            <li><a href="#"><img src="http://jquerymobile.com/demos/1.2.0/docs/lists/images/de.png" alt="Germany" class="ui-li-icon">Germany <span class="ui-li-count">4</span></a></li>
            <li><a href="#"><img src="http://jquerymobile.com/demos/1.2.0/docs/lists/images/gb.png" alt="Great Britain" class="ui-li-icon">Great Britain <span class="ui-li-count">0</span></a></li>
            <li><a href="#"><img src="http://jquerymobile.com/demos/1.2.0/docs/lists/images/fi.png" alt="Finland" class="ui-li-icon">Finland <span class="ui-li-count">12</span></a></li>
            <li><a href="#"><img src="http://jquerymobile.com/demos/1.2.0/docs/lists/images/sj.png" alt="Norway" class="ui-li-icon">Norway <span class="ui-li-count">328</span></a></li>
            <li><a href="#"><img src="http://jquerymobile.com/demos/1.2.0/docs/lists/images/us.png" alt="United States" class="ui-li-icon">United States <span class="ui-li-count">62</span></a></li>
    </ul>
</div>​
于 2012-11-16T13:38:02.127 に答える