JQuery sortable lists and fixed/locked items

前端 未结 9 1566
故里飘歌
故里飘歌 2020-11-28 06:07

Is it possible to lock list items in JQuery sortable list in a way that those items will stay in that particular place in the list.

For example,

consider th

9条回答
  •  难免孤独
    2020-11-28 06:48

    Maybe this will help to someone: use methods "disable" and "enable". Example HTML:

    • You can move me
    • You can't move me.

    Script:

    $('#sortable').sortable();
    $('#sortable').mousedown(function() {
      if($(this).data('state')=='lifeless') $('#sortable').sortable('disable');
      else $('#sortable').sortable('enable');
    });
    

    Live example here: https://jsfiddle.net/ozsvar/0ggqtva5/2/

提交回复
热议问题