0

I nearly have the solution thanks to this question: Draggable revert if outside this div and inside of other draggables (using both invalid and valid revert options)

I have amended the code in jsfiddle here http://jsfiddle.net/phoebebright/jcRN7/1/ to demonstrate what I want to do showing the outside div where items are droppable and an inside div where they are not, easier to demonstrate than to explain!

How can I stop a div being dropped on a div inside a div which is droppable?

Community
  • 1
  • 1
PhoebeB
  • 8,434
  • 8
  • 57
  • 76

1 Answers1

2
$('.drop').droppable({
    tolerance: 'fit',
});

$('.drag').draggable({
    revert: 'invalid',
    stop: function() {
        $(this).draggable('option', 'revert', 'invalid');
    }
});

$('.drag').droppable({
    greedy: true,
    tolerance: 'touch',
    drop: function(event, ui) {
        ui.draggable.draggable('option', 'revert', true);
    }
});

Try adding this:

$('#nogo').droppable({
    greedy: true,
    drop: function(event,ui){
        ui.draggable.draggable('option','revert',true);
    }
});
rekans
  • 342
  • 3
  • 11