我的jquery tablesorter插件有问题。
从我的json源获取新数据后,它不会清除数据 我尝试将tablesorter调用放在不同的地方,但它不断添加自己。
当我注释掉tablesorter调用时,它运行正常。
以下是我使用的代码。
function DailyProduction() {
$('#Container').addClass('daily');
var firstday = Date.today().toString('MM/dd/yyyy');
var lastday = Date.today().toString('MM/dd/yyyy');
$("#ajaxTitle").text("DAILY PRODUCTION REPORT - (" + firstday + ")");
$("#AjaxLoader2").show();
$("#dynamic_rows").empty();
$.getJSON('api/loareports.php?startdate=' + firstday + '&enddate=' + lastday, function(json){
$.each(json,function(i,loainf){
var total = loainf.Avgcallsperhour;
if (total < 15) {
x="style=\"background-color:red; font-weight:bold; font-size:16px;\"";
} // less then 15 is red
else if (total >= 15 && total <= 24) {
x="style=\"background-color:#FFDF00; color:#333; font-weight:bold; font-size:16px;\"";
} // between 15 and 24 yellow
else if (total > 25){
x="style=\"background-color:green; font-weight:bold; font-size:16px;\"";
}else {
x="";
} // above 25 is green
var tblRow =
"<tr " + x + ">"
+"<td align='center'>"+loainf.user_name+"</td>"
+"<td align='center'>"+loainf.last_name+"</td>"
+"<td align='center'>"+loainf.vmin+"</td>"
+"<td align='center'>"+loainf.vcalls+"</td>"
+"<td align='center'>"+loainf.dialavgtime+"</td>"
+"<td align='center'>"+loainf.xmin+"</td>"
+"<td align='center'>"+loainf.xcalls+"</td>"
+"<td align='center'>"+loainf.manualavgtime+"</td>"
+"<td align='center'>"+loainf.tmin+"</td>"
+"<td align='center'>"+loainf.tcalls+"</td>"
+"<td align='center'>"+loainf.totalavgtime+"</td>"
+"<td align='center'>"+loainf.leads+"</td>"
+"<td align='center'>"+loainf.loa+"</td>"
+"</tr>"
$(tblRow).appendTo("#LoaReport tbody");
$("#LoaReport").trigger("update");
});
$("#AjaxLoader2").hide();
$("#LoaReport").tablesorter({
sortList: [[9,1],[1,1]]
});
setTimeout(DailyProduction, 10000);
});
}
我对如何使这项工作感到茫然
#dynamic_rows
是<tbody id="dynamic_rows"></tbody>
,如上所述:
$("#LoaReport").tablesorter({
sortList: [[9,1],[1,1]]
});
它工作正常。
答案 0 :(得分:0)
使用tablesorter进行ajax调用怎么样?