嵌套Jquery Ui中的传播问题可选

问题是:在嵌套的jQuery Ui中可选择,选择上下文的最上层子项意味着当我单击项目1时它选择项目1,但是当我单击项目111或1111时它选择直到项目2而我只需要焦点上的元素是的,不是它的父母,直到鼠标专注于它。

请记住,可能有任何纯HTML,不仅限于ul,li,它仅用于说明目的。

  • Item 1
  • Item 2
    • Item 11
      • Item 111
      • Item 112
      • Item 113
      • Item 114
        • Item 1111
        • Item 1112
        • Item 1113
        • Item 1114
        • Item 1115
      • Item 115
    • Item 12
    • Item 13
    • Item 14
    • Item 15
  • Item 3
  • Item 4
  • Item 5

脚本是

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

小提琴是: – http://jsfiddle.net/z425phwn/2/

我已经通过已经问过的问题,但无法找到解决此问题的任何解决方案,任何帮助都将非常有用!

我想jQuery UI Selectable不是为这种行为而设计的。 但你仍然可以手动完成:

 $(document).ready(function() { $("*").click(function() { $(".ui-selected").removeClass("ui-selected"); var thisEl = $(this); if (thisEl.closest("#selectable").length) { thisEl.addClass("ui-selected"); } return false; }); }); 

更新小提琴 。

另外,要模拟jQuery UI Selectable(并使用其样式),您可以添加以下内容:

 $(document).ready(function() { var selectable = $("#selectable"); selectable.addClass("ui-selectable"); selectable.find("*").addClass("ui-selectee"); }); 

使用distance选项。

距离means tolerance, in pixels, for when selecting should start. If specified, selecting will not start until the mouse has been dragged beyond the specified distance. means tolerance, in pixels, for when selecting should start. If specified, selecting will not start until the mouse has been dragged beyond the specified distance.

例如distance: 10 (10像素),下面的元素将有一个公平的机会接收点击。