此代码将运行,但当列表长度变为3或更大时,它将不会停止接受新项目。基本上它是一个卡堆,当它有3张牌掉进去时,我希望它停止接受牌,如果你拿出一张,我希望它再次接受,直到它达到3.我猜这个列表的长度是没有被重新检查。任何解决这个或替代解决方案的方法都很棒
// let the very important be droppable but accept a max of 3 cards, accepting the gallery items
$vi.droppable({
if ($(vi).length < 3) {
acceptg: "#gallery li",
accepti: "#i li",
acceptni: "#ni li",
activeClass: "ui-state-highlight",
drop: function( event, ui ) {
deleteImage( ui.draggable )
else {
$(vi).droppable( "option", "disabled", true );
}
}
});