jquery – 为什么我可以禁用,但无法启用可放置功能?

我只需要在一个下降区域中使用1个块,然后根据需要进行切换.为什么我可以禁用,但无法启用可放置功能

> $(this).droppable(“option”,“disabled”,false); – 不起作用
> $(this).droppable(“enable”); – 不起作用
> Enable a droppable after it has being disable – 不起作用

这是我的代码

$('.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/

如何通过一个按钮将所有红色块恢复到主要位置?

解决方法

工作演示删除了旧的演示

新演示试试这个:http://jsfiddle.net/7EbKS/

行为:现在当用户移动红色框时,你可以将另一个移到空位,

希望它符合原因:)

$(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",ui) {
                ui.draggable.appendTo($(this)).removeAttr('style');
             }
        });
    }
    $('.my_block').droppable({
        greedy: true,tolerance: 'touch',drop: function(event,ui) {
            ui.draggable.draggable('option',true);
        }
    });

});

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: <span id=&quot...
jQuery 添加水印 <script src="../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...