dynamically enable/disable jquery sortable item

前端 未结 5 1332
南旧
南旧 2021-02-07 15:31

I have table rows that are sortable depending on whether certain radio buttons are checked or not. The sortables are initialized on document.ready as follows:

5条回答
  •  [愿得一人]
    2021-02-07 16:01

    I had a similar problem and found an easy solution (but in my example I am using a sortable ul not a table, as there is more freedom with mark-up in ul's).

    The idea behind it is to leave the list and all its items sortable, but remove the handle, thus disabling the individual item's ability to sort, as seen in this code

    • Item 1

    • Item 2

    • Item 3

    • Item 4

提交回复
热议问题