Reorder table from jqueryUI sortable array
Hello thanks for taking a look at this.
I am using jquery ui sortable on an <ul> whose id's increment from 0 - 16.
It creates an array like this when you sort.
var arr = ["1", "2", "4", "5", "6", "3", "10", "7", "8", "9", "17", "11",
"12", "13", "14", "15", "16"]
I have a method that I pass the list into to. Currently im trying to just
move the row to the new position, but I might have to repaint the table.
Here's the method.
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));
});
}
},
Any help would be appreciated.
No comments:
Post a Comment