how to disable first item of a list from being sortable and drop target

前端 未结 1 1633
没有蜡笔的小新
没有蜡笔的小新 2021-01-20 08:21

I have a list of items and I want to make the first item in the list unsortable and unmovable. The first item in the list should always stay as the first item in the list. H

相关标签:
1条回答
  • 2021-01-20 08:37

    Mmm, hard to say for certain. I've not used sortable/draggable combination before, moreover the UI documentation doesn't expressly address the sortable/draggable combination.

    However, from what I have read in the documentation, something like this should work :

    $(function() {
        $("#lineup li").disableSelection().addClass('ui-state-default').eq(0).addClass('ui-state-disabled');//alternatively, write classes as HTML attributes
        $("#lineup").sortable({
            items: "li:not(.ui-state-disabled)" //should disable draggable and sortable
        });
    });
    
    0 讨论(0)
提交回复
热议问题