javascript - jQuery 可根据元素的属性进行排序

标签 javascript jquery html jquery-ui

我的页面上有几个容器,它们是 .sortable()因此 <div> 中的所有元素可以使用 connectWith 从一个容器移动到另一个容器,来回移动选项。但是,如何防止其中一些元素被删除到特定的可排序列上?

每个元素都有一些特定的属性来描述我 .sortable()容器可以移动。

最佳答案

据我了解,您可以指定可排序放置区域的可能目标:

connectWith

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/

相关文章:

用于显示经过修改以与多个唯一 div 一起使用的 div 的 javascript 代码

javascript - 服务中的 Angular 2 和 rxjs 主题未在组件上更新

jquery - 使用 jQuery 选择嵌套 div

javascript - 如何延迟 gif 从页面加载开始?

javascript - 如何通过ajax将多个变量传递给codeigniter Controller ?一个变量是通过序列化

javascript - 将回调添加到 JavaScript 函数中(AngularJS 上的应用)

jquery 取消脚本后的点击操作

php - Codeigniter 中的 jquery 和 ajax

html - 内容可编辑文本编辑器

javascript - jQuery 在动态加载的 div 上添加类