how to revert position of a jquery UI draggable based on condition

前端 未结 5 2011
孤独总比滥情好
孤独总比滥情好 2020-12-08 04:54

I have an element which is draggable and an element which is droppable. Once the dragged item is dropped on the dropzone I am trying to execute the following jquery psuedo c

5条回答
  •  半阙折子戏
    2020-12-08 05:21

    $("#droppable").droppable({ 
        accept: function(dropElem) {
            //dropElem was the dropped element, return true or false to accept/refuse it
            if($(this).data('stoneclass') == dropElem.attr("id")){
                return true;
        }
    }
    });​
    

    This was used to accept only one draggable, from a group of draggables ; to one correct droppable, in a group of droppables.

    P.S sorry for the language if it is not understandable =)

提交回复
热议问题