JQuery-UI draggable reset to original position

后端 未结 6 1885
自闭症患者
自闭症患者 2020-12-18 22:28

This is probably very easy to do, but I always think too complicated.

I\'ve just set up a simple test with #draggable / #droppable with a fixed width/height + float:

6条回答
  •  無奈伤痛
    2020-12-18 23:04

    I found that the following was the simplest way to reset to original position, but if you want the item to remain draggle this will not work alone

    $(".draggable-item").removeAttr('style');
    

    This worked for me to reset to original position and keep item draggable:

    $("#reset").click(function () {
        // Reset position
        $(".draggable-item").removeAttr('style');
    
        // Destroy original draggable and create new one
        $(".draggable-item").draggable("destroy");
        $(".draggable-item").draggable();
    });
    

提交回复
热议问题