我是jQuery mobile的新手,所有的li都完美地附加在ul中,但只有data-role=slider
不会附加。
function getWebsiteDirectries()
{
var customer = "";
var li = "";
if(user_id.length != 0){
url = serviceURL +'customer-info.json?id='+user_id+'&action=get&request_type=web_directory';
$.getJSON(url, function(json) {
$('#web_list li').remove();
customer = json.items;
$.each(customer, function(key, value) {
$.each(value.customer.customer_toplist, function(key, value) {
li += '<li style="height:40px; line-height:40px;"><span class="f_right"><select data-role="slider" id="'+value.vName+'" name="'+value.vName+'" class="ui-slider-switch"><option value="0">OFF</option><option value="1">ON</option></select></span>'+value.vTitle+'</li>';
});
$('#web_list').append(li);
$('#web_list').listview('refresh');
});
});
}
}
答案 0 :(得分:2)
添加:
$('#web_list').trigger('create');
之间:
$('#web_list').append(li);
$('#web_list').trigger('create');
$('#web_list').listview('refresh');