Disabling individual items in knockout sort

In knockout sorting, I know you can disable the sortable list using isEnabled

in a binding sortable

. I also know that you can turn off the movement of elements using cancelDrop

in function beforeMove

. The problem is that it isEnabled

disables the entire list, or cancelDrop

can only be called after the element has already been dragged and dropped onto another sortable

.

Is there a way to disable sortable

click / drag behavior on some contained elements?

+3


source to share


1 answer


For this purpose you can use jQuery UI items

or cancel

. The docs are here: http://jqueryui.com/sortable/#items .

You would add them to the binding like:

<div class="container" data-bind="sortable: { data: tasks, options: { cancel: '.prevent' } }">

      



or worldwide:

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

      

An example is here: http://jsfiddle.net/rniemeyer/2wEX3/

+8


source







All Articles