jquery ui sortable disable for one li item
Sure, try something like this:
$(".sortable").sortable({ items: "li:not(.unsortable)" }); $(".sortable").disableSelection();
By using the items option you can specify the items that can and can't be sorted.
I know, this question is old. but I let you know right answer. How to dynamically make item disabled and enabled by click.Because I have the same issue at 2016 :D
first of all. All what you need to do is set items to the sortable what will be disabled at start. Add parameter what remove disabled items from the list(it needed on first init):
var sortable = $("#sortable-sections");sortable.sortable({ items: 'li:not(.ui-state-disabled)', helper: 'clone',});sortable.disableSelection();
(bootstrap used in example)
Then just add event listener, I used onClick, so example here:
sortable.find('li').click(function () { $(this).toggleClass('ui-state-disabled'); $(this).hasClass('ui-state-disabled') ? $(this).removeData('sortableItem') : false;});
Sortable-item will be sortable only if he have data what called sortableItem so it will make it dynamically disabled, hope it helps someone.
Cheers!