本文介绍了禁用可剔除分类的单个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在敲除排序中,我知道您可以在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可排序选项itemscancel.此处的文档: 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/

这篇关于禁用可剔除分类的单个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 00:30