javascript - how to sort elements in the array: jQuery -
summary: have table rows added each btn click. using jquery-ui sortable() function move/sort rows.
let have this:
<tbody>   <tr><td>a</td></tr>   <tr><td>b</td></tr>   <tr><td>c</td></tr>   <tr><td>d</td></tr>   <tr><td>e</td></tr>   <tr><td>f</td></tr> </tbody> issue: can move rows using sortable() function. not able update elements in rows. using
$('.report-configuration .configuration-table tbody').sortable({ 'change': function(event, ui){     arr=['a','b','c','d','e','f'];     console.log(ui);     var tmp = arr.splice(ui.originalpostion);//i missing logic here     arr.splice(ui.postion, tmp);     console.log(arr);  }}); i looking logic update positions in array.
after sortable has ended html changed. jquery can select changed html , determine correct sequence.
in change callback function this, note arr has new array correct sequence:
var arr = [] $(this).find('td').each(function() {   arr.push($(this).html()); }); console.log(arr); 
Comments
Post a Comment