我有一个可折叠集,我试图将查询结果作为列表视图附加到该集。但我无法将结果绑定为列表视图。
这就是我想要做的
function queryDB(tx) {
tx.executeSql('SELECT * FROM FOLDER', [], querySuccess, errorCB);
}
function listdata(tx,results){
list= ("<ul data-role='listview' data-inset='false' id='mylist' />");
count = results.rows.length;
$.each(results.rows,function(index){
var row = results.rows.item(index);
var li = '<li><a href="#">'+row['Date']+'</a></li>';
list = $(list).append(li);
});
}
function querySuccess(tx, results) {
$.each(results.rows,function(index){
var row = results.rows.item(index);
tx.executeSql('SELECT Date FROM ALLIGNMENT WHERE name="'+row[name]+'"', [], listdata, errorCB);
var div = '<div data-role="collapsible" data-inset="false" data-iconpos="right" data-collapsible="true" data-collapsed-icon="arrow-r" data-expanded-icon="arrow-d"><h3>'+
row["name"]+'<span class="ui-li-count ui-btn-up-c ui-btn-corner-all" data-iconpos="right">10</span></h3></div>';
$(list).appendTo(div).parent().appendTo('[data-role="content"]').end().trigger("create");
$('div[data-role="collapsible"]').collapsible({theme:'c',refresh:true});
$('[data-role="listview"]').listview().listview('refresh');
});
}
如果我尝试只显示一个可折叠的集合,我可以显示。但是当我尝试显示列表视图时,什么都没有显示。我在做什么错?
谢谢:)
新的功能结构
function queryDB(tx) {
tx.executeSql('SELECT * FROM FOLDER', [], querySuccess, errorCB);
}
function listdata(tx,resultset){
list = $("<ul>").attr({'data-role':'listview','data-inset':'false','id':'mylist'});
count = resultset.rows.length;
$(list).remove();
$.each(resultset.rows,function(index){
var row = resultset.rows.item(index);
// alert(row['CreatedDate']);
var li = '<li><a href="#">'+row['Date']+'</a></li>';
list.append(li);
});
div = '<div data-role="collapsible" data-inset="false" data-iconpos="right" data-collapsible="true" data-collapsed-icon="arrow-r" data-expanded-icon="arrow-d"><h3>'+
row1["name"]+'<span class="ui-li-count ui-btn-up-c ui-btn-corner-all" data-iconpos="right">'+count+'</span></h3></div>';
}
list.appendTo(div).parent().appendTo('[data-role="content"]').end().trigger("create");
$('div[data-role="collapsible"]').collapsible({theme:'b',refresh:true});
$('[data-role="listview"]').listview().listview('refresh');
}
function querySuccess(tx, results) {
$.each(results.rows,function(index){
row1 = results.rows.item(index);
tx.executeSql('SELECT CreatedDate FROM ALLIGNMENT WHERE name="'+row1["name"]+'" ', [], listdata, errorCB);
});
}