JQuery help: drag to Sortable and then drag again

I have a list of items in a drag list that is related to sorting using the connectToSortable parameter. Now I want to remove some items from this sort list and move them back to the drag list. It looks like a cancellation. Suppose that the user has moved 5 items to the sort list and decides that he wants only 4 items, and decides to simply drag the unwanted item from the sort list to the drag list. How to do this without adding the "delete" link in the sort list. Many thanks. For more information see http://the-stickman.com/web-development/javascript/jquery-dropping-items-from-a-draggable-list-to-a-sortable-list/

+3
source share
2 answers

This jQuery UI example seems to be what you need. It has two linked lists, and the user can drag and drop items between them.

, . , , UL LI, UL, (. ), , - , . "out", , , "stop", . ui.position ui.offset , , , .

, .

+5

, - , drop. #priority_articles_list , li.article graggable, #articles. ui.draggable.remove();, .

$("#articles").droppable({
  accept: '#priority_articles_list > li',

  drop: function(ev, ui) {
    draggable_id = "#" + ui.draggable.attr("id").replace("priority_", "");
    $(draggable_id).removeClass("shouldnt_drag");
    ui.draggable.remove();
    if ($("#priority_articles_list").children("li").length == 1) {
      $("#priority_articles p").show();
    }
  }
});
0

Source: https://habr.com/ru/post/1705234/


All Articles