Jquery draggable show qtip while being dragged

假如想象 提交于 2019-12-13 01:24:06

问题


I want to show tootip on an element when it is being dragged and hide it when the element is dropped/reverted.
I am using qtip2 for the tooltip

My Code:

$(".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'
     }
 });

Here is the fiddle: http://jsfiddle.net/e6dJq/

I can see the tooltip when the element is clicked, but it is hidden as soon as the dragging starts. Because a clone is created and the element loses focus.
I am not able to keep the tooltip visible until the mouse click is released. Please help.


回答1:


Try it like this:

$( ".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");
 });

It will call qtip on cloned element.

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



来源:https://stackoverflow.com/questions/22067660/jquery-draggable-show-qtip-while-being-dragged

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!