I need only 1 block in one drop-area and switch if needed. Why I can disable, but can't enable a droppable function?
$(this).droppable("option", "disabled", false); - doesn't work  $(this).droppable("enable"); - doesn't work  Here is my code:
$('.my_block').draggable({
    revert: "invalid",        
});
$('.free').droppable({         
    accept: ".my_block",
    drop: function(ev, ui) {             
        $(this).removeClass("free");    
        $(this).addClass("1");                
        ui.draggable.appendTo($(this)).removeAttr('style');
            $(this).droppable("disable");              
        },
        out:  function(ev, ui) {                     
            $(this).droppable("enable");    
            $(this).removeClass("1");    
            $(this).addClass("free");            
        },        
    });
jsfiddle http://jsfiddle.net/4ABCN/2/
And how can I back all red blocks to main positions by one button?
Working demo Deleted old demo
New Demo Try this: http://jsfiddle.net/7EbKS/
Behaviour: Now when user moves the red box you are allowed to drop another one in empty position,
Hope it fits the cause :)
Code
  $(function() {
    foo();
    $('.my_block').draggable({
        revert: "invalid",
        stop: function() {
            $(this).draggable('option', 'revert', 'invalid');
        }
    });
    function foo() {
        $('.block').droppable({
            greedy: true,
            accept: ".my_block",
            // tolerance: "fit",
            drop: function(ev, ui) {
                ui.draggable.appendTo($(this)).removeAttr('style');
             }
        });
    }
    $('.my_block').droppable({
        greedy: true,
        tolerance: 'touch',
        drop: function(event, ui) {
            ui.draggable.draggable('option', 'revert', true);
        }
    });
});
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With