disabling individual items in knockout-sortable

蹲街弑〆低调 提交于 2020-01-03 19:41:47

问题


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.

Is there a way to disable sortable's click/drag behavior on certain contained items?


回答1:


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' } }">

or globally like:

ko.bindingHandlers.sortable.options.cancel = ".prevent";

Sample here: http://jsfiddle.net/rniemeyer/2wEX3/



来源:https://stackoverflow.com/questions/14611775/disabling-individual-items-in-knockout-sortable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!