Search code examples
jqueryjquery-uiselectablejquery-ui-selectableunselect

jQuery UI Selectable - unselect selected item on click


Does anyone know if there's a way to configure a jquery ui selectable element to unselect the selected element when you click it? Sort of like a toggle. If it's already selected, unselect it, otherwise do the default behavior.

Thanks.


Solution

  • i'm very late in responding to your question, but let me just answer it anyway so that to keep it as a reference for others.

    $( ".selector" ).bind( "mousedown", function ( e ) {
        e.metaKey = true;
    } ).selectable();
    

    this will allow the toggle behavior that you're looking for.