How to remove an item that is pulled away from it's list?

前端 未结 2 849
名媛妹妹
名媛妹妹 2021-01-11 11:42

here is a simple question. I have a \'ul\' which i have made sortable via jquery-ui\'s sortable() function. I want to remove elements when they are dragged off the list.

2条回答
  •  旧巷少年郎
    2021-01-11 12:09

    You could try to use a variable to check if the items you are dragging is dragged out of its parent container.

    You can use the over and out events of the jQuery UI sortable to assign the value for this variable and then execute the removal of the dragged item on the beforeStop event.

    here is a demo of what I have come up with: http://jsfiddle.net/drewP/m7VJq/1/

    let me know if it works for you.

提交回复
热议问题