[英]Click on a draggable initiates dragging
I have a tree structured ul li
element in a page. 我在页面中有一个树状的
ul li
元素。 I made the Leaf li
to be draggable. 我将Leaf
li
设为可拖动。 We can drag and drop these li
between their immediate parent li
. 我们可以将这些
li
拖放到其直接父li
之间。
Everything going fine except one problem. 除了一个问题,一切都很好。 If we click on the
li
, It started dragging and required another click to stop. 如果单击
li
,它将开始拖动并需要再次单击才能停止。
Just for information, We are using jquery treeview plugin to make this ul li
structure a treeview. 仅供参考,我们正在使用jquery treeview插件使此
ul li
结构成为treeview。
Any help regarding this would be appreciated. 关于此的任何帮助将不胜感激。
Try using the Delay option when initializing the Draggable plugin. 初始化Draggable插件时,请尝试使用Delay选项。 Setting this to 250 ms or something will delay the dragging so that if the user just clicks on the element it won't start dragging.
将其设置为250毫秒或其他时间会延迟拖动,因此,如果用户仅单击元素,它将不会开始拖动。
http://api.jqueryui.com/draggable/#option-delay http://api.jqueryui.com/draggable/#option-delay
we had a similar kind of issue due to the clash of Jquery Context Menu and draggable. 由于Jquery Context Menu和draggable的冲突,我们遇到了类似的问题。
Update below code in jquery Context menu script file. 更新jquery上下文菜单脚本文件中的以下代码。
Ref : jQuery Context Menu clashes with jQuery Draggable for more info. 参考: jQuery上下文菜单与jQuery Draggable相冲突以获取更多信息。
jQuery(this).mousedown( function(e) {
var evt = e;
if (e.button == 2) //Added to make this compatible with draggable
evt.stopPropagation();
jQuery(this).mouseup( function(e) {
if (e.button == 2) //Added to make this compatible with draggable
e.stopPropagation();
var srcElement = jQuery(this);
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.