我的页面上有几个容器,它们是 .sortable()
因此 <div>
中的所有元素可以使用 connectWith
从一个容器移动到另一个容器,来回移动选项。但是,如何防止其中一些元素被删除到特定的可排序列上?
每个元素都有一些特定的属性来描述我 .sortable()
容器可以移动。
最佳答案
据我了解,您可以指定可排序放置区域的可能目标:
Type: Selector
Default: false
A selector of other sortable elements that the items from this list should be connected to. This is a one-way relationship, if you want the items to be connected in both directions, the connectWith option must be set on both sortable elements. Code examples: Initialize the sortable with the connectWith option specified:
$( ".selector" ).sortable({ connectWith: "#shopping-cart" });
Get or set the connectWith option, after initialization:
// Getter var connectWith = $( ".selector" ).sortable( "option", "connectWith" ); // Setter $( ".selector" ).sortable( "option", "connectWith", "#shopping-cart" );
为了更精确,请使用类似:api.jqueryui.com/sortable/#event-receive
关于javascript - jQuery 可根据元素的属性进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32090230/