I looking for solution to my issue . Is there in jQuery UI in Draggable possibility to check for which element of DOM the object is dragged ?
I know there is no problem if we are talking about droppable, here we have option to get dragged element id, but what in other case ?
I need to restrict drag and drop in arrays of booleans. So when element is dragged into droggable I would like to check if boolean is true or false on this particular droppable.
Thanks in advance
Here is the solution for your problem:
You need to pass "accept" parameter to the droppable on the page, like this:
$("#droppable").droppable({
accept: function (source) {
// return true, if droppable accepts given source (draggable)
return $(source).attr('id') == 'draggable'
},
drop: function (event, ui) {
// here $(this) is droppable where the drop occured.
$(this).html("Dropped!");
}
});
The complete working example here: http://jsfiddle.net/akhikhl/3KaaH/1/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.