【发布时间】:2013-11-30 23:50:26
【问题描述】:
在 jQuerymobile 列表视图中动态添加的复选框未正确呈现。
在无序列表下方查找。我在 HTML 本身中添加了一个示例列表项。
<ul data-role="listview" id="ul_address_list" >
<li data-icon="false"><a href="#" class="add-container">
<label class="add-container" data-corners="false">
<input type="checkbox" value="true" />
<label class="lbl_add-container">
<h3>Header</h3>
<p>Content</p>
</label>
</label>
</li>
</ul>
以下是上述代码的输出。哪个渲染正确。
现在我正在尝试使用 jQuery 的 append 函数动态添加列表项。
$.each(obj_address_list, function (ctr, obj) {
$('#ul_address_list').append('<li data-icon="false">' +
'<a href="#" class="add-container">' +
'<label class="add-container" data-corners="false">' +
'<input type="checkbox" value="true" />' +
'<label class="lbl_add-container">' +
'<h3>Header</h3>' +
'<p>content</p></div>' +
'</label>' +
'</label>' +
'</a>' +
'</li>');
});
$('#ul_address_list').listview('refresh');
下面是上述代码的输出。显示不正确。
为什么动态添加的列表项没有正确呈现?
【问题讨论】:
标签: javascript jquery jquery-mobile