Good day. This kind of problem. I create a project in which there are many sortable lists and elements can be created dynamically. I faced the following problem, which I cannot solve yet: during my work, the parent elements and children are dynamically created, the children inside the parents should be sorted, everything happens without reloading the page when loading all the created lists are sorted, and the dynamically created parent-child links they do not even want to notice after the forced assignment that even after a second after loading the appointment of the sortable list does not work
there is a function:
function _sortable(list,elements,handle_s) { $(list).sortable({ handle: handle_s, update: function () { length = $(elements).length; var sort = length; var arr = {}; arr["table_name"] = $("#table_name").val(); setTimeout(function () { for (var i = 0; i < length; i++) { var sort_id = $(elements + ":eq(" + i + ") .id_hidden").val(); arr[sort] = sort_id; sort--; } $.ajax({ type: "POST", url: '/php/sort.php', data: arr, dataType: 'json', success: function (response) { alert(response) } }); }, 350); } }); }; if i let it run while the script is running
_sortable("#list", ".item_level1", ".handle_main"); everything is working
if I do timing for a second
setTimeout(function () { _sortable("#list", ".item_level1", ".handle_main"); }, 1000); it stops