javascript中的listview排序
我有标题、图片和日期的列表视图。我想根据日期字段对列表进行排序,然后显示在html5页面中。我在这方面使用了jquery和html5javascript中的listview排序,javascript,jquery,html,Javascript,Jquery,Html,我有标题、图片和日期的列表视图。我想根据日期字段对列表进行排序,然后显示在html5页面中。我在这方面使用了jquery和html5 $j('#task_summary_list').empty(); if (response.totalSize > 0) { $j.each(response.records, function(i, record) { var imgName; switch (record.Priority) {
$j('#task_summary_list').empty();
if (response.totalSize > 0) {
$j.each(response.records, function(i, record) {
var imgName;
switch (record.Priority) {
case "High":
imgName = "images/prio_high24.png";
break;
case "Low":
imgName = "images/prio_low24.png";
break;
default:
imgName = "images/prio_normal24.png";
}
// create new list entry for record to the listview
$j('<li></li>')
.attr('id', record.Id)
.hide()
.append(
'<a href="#">' + '<img src="' + imgName
+ '" alt="High" class="ui-li-icon">'
+ '<h1>'
+ record.Subject + '</h1>'
+ '<p>' + '<strong>'
+ record.ActivityDate + '</strong>' + '</p>'
+ '</a>')
.click(function(e) {
e.preventDefault();
console.log("Under onSuccessTasks " + record.Id);
showTaskDetails(record);
})
.appendTo('#task_summary_list')
.show();
});
}
else {
$j('<li class="norecord">No records to display</li>').appendTo('#task_summary_list');
}
$j('#task_summary_list').listview('refresh');
$j.mobile.hidePageLoadingMsg();
$j(“#任务(摘要)列表”).empty();
如果(response.totalSize>0){
每个$j(响应记录、功能(i、记录){
var imgName;
开关(记录优先级){
案例“高”:
imgName=“images/prio_high24.png”;
打破
案例“低”:
imgName=“images/prio_low24.png”;
打破
违约:
imgName=“images/prio_normal24.png”;
}
//为listview中的记录创建新的列表条目
$j(“”)
.attr('id',record.id)
.hide()
.附加(
'')
。单击(功能(e){
e、 预防默认值();
log(“onSuccessTasks下”+record.Id);
显示任务详细信息(记录);
})
.appendTo(“#任务"摘要"列表”)
.show();
});
}
否则{
$j('没有要显示的记录。 ”)。附加到(“#任务摘要#列表”);
}
$j(“#任务"摘要"列表”).listview('refresh');
$j.mobile.hidePageLoadingMsg();
感谢您的帮助。
感谢avance。在我的应用程序中,我使用sql查询,所以我在主查询之后使用OrderBy子句,数据以排序形式显示在UI上
$('#dateDiv').sortElements(function(a, b){
return Date.parse($(a).text()) > Date.parse($(b).text()) ? 1 : -1;
});
谢谢