问题描述
在敲除排序中,我知道您可以在sortable
绑定中使用isEnabled
禁用可排序列表.我也知道您可以在beforeMove
函数中使用cancelDrop
禁用移动项.问题是isEnabled
禁用了整个列表,并且cancelDrop
仅在将项目拖放到另一个sortable
上之后才能调用.
In knockout-sortable, I know that you can disable a sortable list using isEnabled
in the sortable
binding. I also know you can disable moving items using cancelDrop
in a beforeMove
function. The problem is, isEnabled
disables the whole list, and cancelDrop
can only be called after the item is already dragged and dropped onto another sortable
.
是否可以在某些包含的项目上禁用sortable
的点击/拖动行为?
Is there a way to disable sortable
's click/drag behavior on certain contained items?
推荐答案
您可以为此目的使用jQuery UI可排序选项items
或cancel
.此处的文档: http://jqueryui.com/sortable/#items .
You can use the jQuery UI sortable options items
or cancel
for this purpose. Docs here: http://jqueryui.com/sortable/#items.
您可以将它们添加到绑定中,例如:
You would add them in a binding like:
<div class="container" data-bind="sortable: { data: tasks, options: { cancel: '.prevent' } }">
或全局类似:
ko.bindingHandlers.sortable.options.cancel = ".prevent";
此处提供示例: http://jsfiddle.net/rniemeyer/2wEX3/
这篇关于禁用可剔除分类的单个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!