My question is very similar to this one: disabling individual items in knockout-sortable
But the accepted answer keeps the item as a drop target. (The item itself isn't draggable, but you can drop items on top of it). I'm wondering if there's a good way to disable the item completely. jQuery recommends never enabling it in the first place like so: ( http://jqueryui.com/sortable/#items )
$( "#sortable1" ).sortable({
items: "li:not(.ui-state-disabled)"
});
But I'm not sure how to use that logic with the "sortable" binding.
Since this only really applies to items at the beginning or end of the list, I could potentially add them separately from the "sortable" bind. But if there's a somewhat elegant way to do it otherwise, I'd be better off with that. I have the feeling I'm missing an obvious way built in to the knockout-sortable plugin.
Taking from the answer you mentioned, is this what you're trying to achieve?
<div class="container" data-bind="sortable: { data: tasks, options: { items: 'li:not(.ui-state-disabled)' } }">
Globally:
ko.bindingHandlers.sortable.options.cancel = "li:not(.ui-state-disabled)";