How to enable dblclick event for elements that were bound to jQuery UI?

In my case, I have UL with the plugin JQuery UI Selectable, but at the same time I want the element associated with selectable pluginto do something when I have double clickthis element. But it seems that JQuery UI Selectable plugin had block the dblclick event. So how can I make it work?

eg:

<script>
    $(function() {
        $( "#selectable" ).selectable();

                $( "#selectable" ).dblclick(function(){
                    // do something here
                })
    });
    </script>

<ul id="selectable">
    <li class="ui-widget-content">Item 1</li>
    <li class="ui-widget-content">Item 2</li>
    <li class="ui-widget-content">Item 3</li>
    <li class="ui-widget-content">Item 4</li>
    <li class="ui-widget-content">Item 5</li>
    <li class="ui-widget-content">Item 6</li>
    <li class="ui-widget-content">Item 7</li>
</ul>

Many thanks!

+5
source share
6 answers

In jQuery you can bind events, for example:

$( "#selectable" ).selectable().dblclick();

Bit. I am not sure if this will work, because both events are click events.

-6
source

.ui-selected, , , b/c, .ui-selected items.

$('#selectable').selectable({ 
  cancel: '.ui-selected' 
});

, . ,

$('.ui-selected').on('click', function() {
  $(this)
    .removeClass('ui-selected')
    .parents('.ui-selectable')
    .trigger('selectablestop');

  // you might also want to trigger selectablestop.
});
+16

a > 0 .

$("#selectable").selectable({
    distance: 1
});

. http://forum.jquery.com/topic/selectable-dosn-t-fire-click-event

+4
$("#selectable li").mousedown(function(event) {
    if(event.which==1)
    {
        if($(event.currentTarget).data('oneclck')==1)
        {
            alert('click');

            return false;
        }
        else
        {
            $(this).data('oneclck', 1);
            setTimeout(function(){
                $(event.currentTarget).data('oneclck', 0);
            }, 200);
        }
    }
});
+3

, onmousedown ( div, .) , , JQUERY UI. , , . - , !: D

, :

<script>
    var content = $('#content').selectable();

    var _mouseStart = content.data('selectable')['_mouseStart'];

    content.data('selectable')['_mouseStart'] = function(e) {
        _mouseStart.call(this, e);
        this.helper.css({
            "top": -1,
            "left": -1
        });
    };
</script>

post

0

, .

$("ul").selectable({
    filter: "li"
});

$("ul").on("mousedown","li",function(e){
    var n = ($(e.toElement).is(".ui-selected")) ? 1 : 0;
    $("#filelist").selectable( "option", "distance", n );
});

When the user starts clicking on the selected items, I set distanceto one so that he does not block the double-click event, but I am available if the user really starts to select.

0
source

All Articles