使用jQuery,在元素上设置Draggable可以防止在单击可拖动元素时触发模糊 [英] Using jQuery, setting Draggable on an element prevents blur from firing when you click the draggable element

查看:91
本文介绍了使用jQuery,在元素上设置Draggable可以防止在单击可拖动元素时触发模糊的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用jQuery,当您在文本框上设置模糊事件并将另一个元素设置为可拖动时,单击可拖动元素时,模糊事件不会在FireFox中触发。 IE有点好,你得到模糊事件,但你没有得到可拖动元素上的click事件。

Using jQuery, when you set a blur event on a text box and set another element as draggable, when you click the draggable element, the blur event does not fire in FireFox. IE is a little better, you get the blur event but you don't get the click event on the draggable element.

如果你没有指定取消: 在可拖动的构造函数中,你将触发模糊事件,但是你想要拖动的元素是不可拖动的。

If you don't specify the cancel: "" in the draggable constructor, you will get the blur event to fire, but then the element you want to drag is not draggable.

jQuery v1.3.2
jQuery UI v1.7.2

jQuery v1.3.2 jQuery UI v1.7.2

console.log行适用于FireFox的FireBug插件。

The console.log lines are for FireFox's FireBug plugin.

<HTML> 
    <HEAD> 
        <TITLE>Blur/Click Workbench</TITLE> 
        <script src="js/jquery.js" type="text/javascript" ></script>
        <script src="js/ui/ui.core.js" type="text/javascript"></script>
        <script src="js/ui/ui.draggable.js" type="text/javascript"></script>
        <script type="text/javascript"> 
function blurring() {
    console.log('1 - blurring - ' + $( this ).attr('id'));
}

function clicking() {
    console.log('2 - clicking - ' + $( this ).attr('id'));
}

$(document).ready(function() {
    $( ".draggableTool" ).draggable( { cancel: "" } );

    $( '.property' ).blur( blurring );
    $( '#labelContainer' ).click( clicking );
});
        </script>
    </HEAD>
    <BODY>
        <input type='text' class='property' id='tb1' />
        <br />
        <input type='text' class='property' id='tb2' />
        <br />
        <label class='draggableTool' id='labelContainer' style='height:20px;position:absolute;'>
            <textarea id='taLabel' style='height:100%;background-color:white;border:1px solid grey;'>Label</textarea>
        </label>
    </BODY>
</HTML>


推荐答案

我遇到了同样的问题。这是一个错误。有关解决方案,请参阅此处: http://dev.jqueryui.com/ticket/4261

I had the same problem. It's a bug. For a solution see here: http://dev.jqueryui.com/ticket/4261

这篇关于使用jQuery,在元素上设置Draggable可以防止在单击可拖动元素时触发模糊的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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