Prevent drop of list item in JqueryUI sortable

前端 未结 8 2064
情歌与酒
情歌与酒 2020-12-23 22:19

I have two lists #sortable1 and #sortable 2 which are connected sortables, as shown in this example.

You can drag and drop list items from

8条回答
  •  渐次进展
    2020-12-23 22:36

    After a few experiments, I've found that by far the easiest method is to use the remove event, that essentially only fires when you try to drop an item into a new sortable (that was previously made available as a target using connectWith).

    Simply add this to your sortable call:

    remove:function(e,ui) {
        if(ui.item.hasClass('your_restricted_classname')) return false;
    },
    

提交回复
热议问题