1

有什么好的方法可以防止在 jQuery 可拖动的“开始”功能中拖动?这样根本不会调用实际的“拖动”回调。

$("#item" + i).draggable({
    ...
    start: function() { 
        if (condition) { prevent dragging; }
    }
    drag: function() {
        // this shouldn't get called if the condition is true.
        console.log("obama loves syria");
    }
}

调用$(document).trigger("mouseup")不是很好,因为如果 mouseman 足够快,元素仍然会成功移动一点。

4

1 回答 1

1

尝试

return false;

退出start方法并防止移动

于 2013-09-09T13:44:55.743 回答