I have a listview, all nicely displayed. I add an item to it, using the exact same function I used to put the original items in it with. If I don't refresh the listview, the new item doesn't get enhanced (no surprise there). But when I DO call refresh, the enhancement is incomplete.
Here's the item as entered:
<li data-role="fieldcontain" id="flip-li-38">
<div class="containing-element">
<label for="flip-38">A B:</label>
<select name="flip-38" id="flip-38" data-role="slider" data-mini="true">
<option value="off">Absent</option>
<option value="on">Present</option>
</select>
</div>
</li>
Here's the item after enhancement:
<li data-role="fieldcontain" id="flip-li-38" class="ui-li ui-li-static ui-body-c">
<div class="containing-element">
<label for="flip-38">A B:</label>
<select name="flip-38" id="flip-38" data-role="slider" data-mini="true">
<option value="off">Absent</option>
<option value="on">Present</option>
</select>
</div>
</li>
But here's one of the items originally in the list:
<li data-role="fieldcontain" id="flip-li-37" class="ui-li ui-li-static ui-body-c ui-field-contain ui-body ui-br">
<div class="containing-element">
<label for="flip-37" id="flip-37-label" class="ui-slider">X Y:</label>
<select name="flip-37" id="flip-37" data-role="slider" data-mini="true" class="ui-slider-switch">
<option value="off">Absent</option>
<option value="on">Present</option>
</select>
<div role="application" class="ui-slider ui-slider-switch ui-btn-down-c ui-btn-corner-all ui-slider-mini" style>
<span class="ui-slider-label ui-slider-label-a ui-btn-active ui-btn-corner-all" role="img" style="width: 0%; ">Present</span>
<span class="ui-slider-label ui-slider-label-b ui-btn-down-c ui-btn-corner-all" role="img" style="width: 100%; ">Absent</span>
<div class="ui-slider-inneroffset">
<a href="#" class="ui-slider-handle ui-btn ui-btn-up-c ui-shadow ui-btn-corner-all ui-slider-handle-snapping" data-corners="true" data-shadow="true" data-iconshadow="true" data-wrapperels="span" data-theme="c" role="slider" aria-valuemin="0" aria-valuemax="1" aria-valuenow="off" aria-valuetext="Absent" title="Absent" aria-labelledby="flip-37-label" style="left: 0%; ">
<span class="ui-btn-inner ui-btn-corner-all">…</span>
</a>
</div>
</div>
</div>
</li>
Here's the surrounding context:
<div id="memberPage" data-role="page">
<div data-role="content">
<form>
<ul data-role="listview" data-filter="true" id="memberList"></ul>
</form>
</div><!-- /content -->
</div>
There might be some kind of timing issue; I captured the partially-enhanced item by writing it to the console, but wrote it BEFORE the call to refresh (which, if I leave the call to refresh out, logs the original unenhanced item).
If it matters, the item gets added from a dialog through the onclick property of a button that links back to the page with the list (thus closing the dialog).
Thanks in advance for any insights.
Try with
$('#memberList').trigger('create');
instead ofrefresh
method of listview. I think it might work as you have to enhance not only the new list item but also the slider inside it.