Klaus Hartl wrote:
The plugin could of course be changed to take tr elements instead of
passing indices and you don't need to handle the rowIndex:
jQuery.fn.moveRow = function(from, to, useBefore) {
var trs = this.find(">tr");
$(from)['insert' + (useBefore && 'Before' || 'After')](to);
return this;
};
Usage:
var from = $('tr:eq(3)'); // 4th row
var to = $('tr:eq(0)'); // 1st row
$('tbody').moveRow(from, to); // insert 4th row after 1st row
Is that what you need?
Well, in that case I just realized that it doesn't make much sense as a
plugin...:
function moveRow(from, to, useBefore) {
from['insert' + (useBefore && 'Before' || 'After')](to);
}
That's all you need then.
--Klaus