Hello! The site uses a javascript plugin that allows you to drag and drop list items. It normally connects and works. But now it was sometimes necessary to initialize the plugin when ajax was updated on a part of the page using the parameter. Here is the initialization code:

$("#all_packages_ul_"+PACKAGING_ID_GLOB).dragsort({ dragSelector: "div", dragEnd: saveOrder_packages_6, placeHolderTemplate: "<li class='placeHolder'><div></div></li>" вместо 6 должно тоже стоять выражение из переменной PACKAGING_ID_GLOB, не знаю как его туда подставить и возможно ли это, т.е. динамически формировать название функции 
  • At the end of the 'drag' event, the function saveOrder_packages_6 () is called, do I understand correctly? Those. there are functions saveOrder_packages_1 (), saveOrder_packages_2 () ... and so with all the values ​​of PACKAGING_ID_GLOB? - Zhukov Roman
  • yes, that's right - masha2


1 answer 1

No need to form anything. The pointer to the dragged element is passed to the dragEnd function. Item Id must be unique throughout the document. I think something like this will do.

 $('ul.package').dragsort(dragSelector:'li',dragEnd:save_order); function save_order(el) { //el - перетащенный элемент //$(el).parent().attr('id') - id контейнера (ul) } 
  • Thank. And how to transfer the pointer to the moved element to the dragEnd function? - masha2