How to prevent multiple selection in jQuery UI Selectable plugin

前端 未结 10 1868
走了就别回头了
走了就别回头了 2020-12-30 00:13

I am using jQuery UI Selectable plugin. I want to select one item at a time. But jQuery UI Selectable plugin allows multiple selection by clicking/ dragging / holding CTRL

10条回答
  •  旧巷少年郎
    2020-12-30 00:33

    This worked for me. It prevents "lassoing" multiple rows and ctrl + click.

    $(function() {
    $("#selectable").selectable({
          selecting: function(event, ui){
                if( $(".ui-selected, .ui-selecting").length > 1){
                      $(ui.selecting).removeClass("ui-selecting");
                }
          }
    });
    });
    

提交回复
热议问题