【问题标题】:Prevent jQuery dragging in "start"防止 jQuery 在“开始”中拖动
【发布时间】:2013-09-09 13:19:01
【问题描述】:

有什么好的方法可以防止在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 足够快,元素仍然会成功移动一点。

【问题讨论】:

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


    【解决方案1】:

    试试

    return false;
    

    退出start方法并阻止移动

    【讨论】:

    • 是的,就是这么简单!非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-16
    • 1970-01-01
    • 1970-01-01
    • 2013-08-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多