jQuery UI:拖动开始时,在可拖动克隆上删除Bootstrap工具提示吗? [英] JQuery UI: remove Bootstrap tooltip on a draggable clone when drag starts?

查看:74
本文介绍了jQuery UI:拖动开始时,在可拖动克隆上删除Bootstrap工具提示吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JQuery UI拖放项目.

I am using JQuery UI for drag and drop in my project.

在可拖动元素上,我有Bootstrap(3.x)工具提示.

On the draggable element, I have Bootstrap (3.x) tooltip.

将鼠标移到可拖动对象上会显示工具提示.

Moving the mouse over the draggable shows the tooltip.

我希望在拖动开始时删除/隐藏可拖动克隆上的工具提示.我进行了测试,但没有成功.

I hope to remove/hide tooltip on the draggable clone when drag starts. I goolged and tested, but to no success.

这是整个事情的jsfiddle设置.链接: http://jsfiddle.net/mddc/6md9h/18/

Here is jsfiddle setup of the whole thing. Link: http://jsfiddle.net/mddc/6md9h/18/

<div id="draggable" class="ui-widget-content">
  <div data-toggle="tooltip" data-original-title="Tooltip to disappear when drag starts.">Drag me</div>
</div>

<div id="droppable" class="ui-widget-header">
  <p>Drop here</p>
</div>

这是JavaScript代码:

Here is javascript code:

 $(function() {
     $( "#draggable" ).draggable({
         start: function(event, ui) {
             //this is what I hope to work, but not working!
             $(ui.helper).find('[data-toggle="tooltip"]').tooltip('hide');
         }, 
        helper: 'clone',
        revert: "invalid"
     });

    $( "#droppable" ).droppable({
      drop: function( event, ui ) {
        $( this )
          .addClass( "ui-state-highlight" )
          .find( "p" )
            .html( "Dropped!" );
      }
    });

    $('[data-toggle="tooltip"]').tooltip({
        'animation': true,
        'placement': 'bottom' 
    });     
  });

感谢您的帮助!

推荐答案

您可以隐藏tooltip子元素.

代码:

 $( "#draggable" ).draggable({
     start: function(event, ui) {             
         $(ui.helper).find('.tooltip').hide();             
     }, 
    helper: 'clone',
    revert: "invalid"
 });

演示: http://jsfiddle.net/9RwHh/

这篇关于jQuery UI:拖动开始时,在可拖动克隆上删除Bootstrap工具提示吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆