How to cancel a drop action for jQuery droppable? -
i have jquery ui droppable accepts draggables. want not allow drop action if conditions met.
how cancel drop action , revert action?
the accept
option on droppable widget:
all draggables match selector accepted. if function specified, function called each draggable on page (passed first argument function), provide custom filter. function should return true if draggable should accepted.
combined revert
option on draggable should need:
$(".draggable").draggable({ revert: 'invalid' }); $("#droppable").droppable({ accept: function(el) { /* filter function, can perform logic here depending on element being filtered: */ return el.hasclass('acceptable'); } });
note in specific example, write accept: ".acceptable"
, make droppable accept elements class acceptable
. option when custom event happens, apply or remove acceptable
class necessary.
here's example: http://jsfiddle.net/andrewwhitaker/rugjf/3/
the bottom has link toggling "acceptability" on off.
Comments
Post a Comment