javascript - "start"中防止 jQuery 拖动

标签 javascript jquery jquery-ui draggable jquery-ui-draggable

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

$("#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 足够快,元素仍然会成功移动一点。

最佳答案

尝试使用

return false;

退出start方法并阻止移动

关于javascript - "start"中防止 jQuery 拖动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18699169/

相关文章:

javascript - 在 Mac OSX 中小尺寸时无法单击 SWF

javascript - php 重定向包括增加

javascript - jQuery - 点击功能不会触发

jquery - 如何在 droppable 中拖动后更改类 css

javascript - jquery-ui : drop&drag inventory with stackable items

javascript - 使用 Package.json 在 $HOME/Sites 文件夹中创建一个文件夹

javascript - 如何定位固定元素

javascript - jQuery text() 方法加载

javascript - 对浏览器停止按钮单击执行操作

php - PHP 注册表出现错误