2
我正在使用JoeQuery的Stupid-Table jQuery插件對簡單表進行排序。我不知道如何刷新動態表格上的整個排序緩存。如何在動態表更新後刷新整個表的排序緩存?
updateSortVal
函數允許更新單個單元格。例如:
$age_td.updateSortVal(23);
但我怎麼能刷新整個表格整個thead
和tbody
更換時?
這裏是我的代碼:
$.ajax({
...
success: function(data) {
$("#myTable thead, #myTable tbody").empty();
if (data.data.length > 0) {
var $thead_tr;
var $tbody_tr;
for (var r = 0; r < data.data.length; r++) {
if (r == 0) $thead_tr = $("<tr>").appendTo("#myTable thead");
$tbody_tr = $("<tr>").appendTo("#myTable tbody");
for (var c in data.data[r]) {
if (r == 0) $("<th>").html(c).appendTo($thead_tr);
$("<td>").html(data.data[r][c]).appendTo($tbody_tr);
// I've tried adding `.updateSortVal(data.data[r][c]);`
// to the above as well, but the cache for the `th`
// needs to be re-cached as well, so let's do it all at once
}
}
// I'd like to refresh the entire stupidtable cache here
$("#myTable").stupidtable().show();
}
}
}
});
好主意。但它沒有刷新緩存。我知道沒有jsfiddle這很難。感謝您的嘗試。 – Ryan 2015-02-24 17:34:30
看到我編輯的答案來檢查小提琴 – 2015-02-24 18:20:50
小提琴的作品!你有沒有改變愚蠢的桌子js? – Ryan 2015-02-24 18:24:11