Jquery UI - 在Container/Parent Div中可拖动和可排序

Ezh*_*per 3 html css jquery jquery-ui

在此输入图像描述

在拖动<div>进行排序的同时,如果我拖动容器外的任何框,它就会出现在容器之外<div>.我不想要这个.

我除了输出是排序时,拖动(例如绿色背景div之上)<div>不应该在父/容器DIV之外.

演示链接

$(function () {
  $(".drag_wrapper").sortable({
    connectWith: ".drag_wrapper"
  }).disableSelection();
});
Run Code Online (Sandbox Code Playgroud)

rdu*_*bya 5

我想你正在寻找收容选项:

$(function () {
    $(".drag_wrapper").sortable({
        connectWith: ".drag_wrapper",
        containment: ".drag_wrapper"
    }).disableSelection();
});
Run Code Online (Sandbox Code Playgroud)