2014-02-27 42 views
1

当元素被拖拽/还原时,我想在元素被拖拽时显示tootip并隐藏它。
我使用qtip2工具提示Jquery被拖拽时显示的qtip

我的代码:

$(".noDrop").qtip({ 
    content: "You cannot drop this item", 
    show: "mousedown", 
    position: { 
     target: 'mouse', 
     viewport: $(window) // Keep it on-screen at all times if possible 
    }, 
    hide: { 
     fixed: true, // Helps to prevent the tooltip from hiding ocassionally when tracking! 
     event: 'mouseup' 
    } 
}); 

这里是小提琴:http://jsfiddle.net/e6dJq/

我可以看到提示被点击的元素时,却是尽快隐藏随着拖动开始。因为创建了一个克隆并且元素失去了焦点。
我不能保持工具提示可见,直到发布鼠标单击。请帮忙。

回答

2

试试这样说:

$(".noDrop").on("dragstart", function(event, ui) { 

    $(".ui-draggable-dragging").qtip(
     content: "You cannot drop this item", 
     position: { 
      target: 'mouse', 
      viewport: $(window) // Keep it on-screen at all times if possible 
     }, 
     hide: { 
      fixed: true, // Helps to prevent the tooltip from hiding ocassionally when tracking! 
      event: 'mouseup' 
     } 
    }).qtip("show"); 
}); 

它将调用克隆元素上qtip。

http://jsfiddle.net/e6dJq/2/

enter image description here

+0

http://jsfiddle.net/e6dJq/1/。该工具提示完全不显示:( – EvilDevil

+0

答案已更新,用小提琴进行测试并正在工作 –

+0

它正在工作,但是,除非我将鼠标悬停在它们上方,否则工具提示将保持打开状态(编辑您的答案以供截图供参考) – EvilDevil