0
我正在使用jQuery ui排序在<ul>
上,其編號從0到16的增量。它會創建一個像這樣的數組。從jqueryUI排序表中排序表
var arr = ["1", "2", "4", "5", "6", "3", "10", "7", "8", "9", "17", "11", "12", "13", "14", "15", "16"]
我有一個方法,我將列表傳遞給。目前我正試圖將列移動到新的位置,但我很確定它不會工作,我將不得不重新繪製表格。這是方法。
positionColumns: function(list) {
var _this = this;
if (!list) list = this.order;
$(list).each(function(i, val) {
if (parseInt(val, 10) !== _this.order[i]) {
work(val, _this.order[i]);
console.log(list);
console.log(_this.order[i]);
} else {
return;
}
});
function work(from, to) {
var table = $('#dealbook-table');
var rows = $('tr', table);
var cols;
rows.each(function(i, row) {
cols = $(row).children('th, td');
console.log(cols);
cols.eq(from).detach().insertBefore(cols.eq(to));
});
}
},
this.order
是拖放之前表的狀態。
任何有識之士將不勝感激。