我只在其他几个地方看到过这个问题的几个变体,特别是这里和这里。
基本上,我有一个棋盘,棋盘上的每个方块都是可放置的,每个棋子都是可拖动的。每个方块一次只能有一块,我试图根据方块上是否有一块来切换启用/禁用方法。
这是我到目前为止所获得的链接:http: //jsbin.com/ayalaz,下面是最相关的代码。
function handleDrop(e, ui) {
            var tileNumber = $(this).data('tile');
            // Make the gamepiece snap into the tile
            ui.draggable
                .data({ // WHAT IF PIECE IS SET BACK DOWN IN SAME TILE... CHECK FOR IT!
                    'preRow': ui.draggable.data('curRow'),
                    'preCol': ui.draggable.data('curCol'),
                    'curRow': $(this).data('row'),
                    'curCol': $(this).data('col')
                });
            $(this).append($(ui.draggable));
            ui.draggable
                .position({
                    of: $(this),
                    my: 'left top',
                    at: 'left top'
                });
            $(this).droppable('disable');
            //console.log("Gamepiece set down at: (" + $(this).data('row') + "," + $(this).data('col')+ ")");
        }
function handleOut(e, ui) {
            // HOW TO TOGGLE DROPPABLE??
            $(this).droppable('enable');
        }
有什么建议吗?
提前致谢!杰里米