2012-03-09 23 views
0

Jquery UIの選択可能なプラグインで、大規模な表のグリッドの異なる部分で複数のセルを選択できます。通常、ある項目をクリックすると、ユーザーが修飾キーを押さない限り、他の項目の選択が解除されます。この現象はjQuery Selectable demoで確認できます。キーボードを使わずにマウスの上にある強調表示されたセルの選択を解除する方法を教えてください。JQuery UIの選択可能なプラグインで複数の項目を選択する

+0

の例では、 - [jsfiddle](HTTP://www.jsfiddle)上のインスタンスのために - 私たちはあなたの問題を想像する方がはるかに簡単になります。 –

+2

ドキュメントでは、「アイテムを選択するにはカーソルを使用してボックスを描画します。隣接しない複数のアイテムを選択するにはCtrlキーを押したままにしてください」 –

+0

@Didier Ghys-私が欲しいのはここです:http://jqueryui.com/demos/selectable /#display-gridただし、マウスの上にある前の選択を解除し、新しいセルを選択します。 –

答えて

2

一つの可能​​な解決策:

<style> 
    #feedback { font-size: 1.4em; } 
    #selectable .ui-selecting { background: #FECA40; } 
    #selectable .ui-selected { background: #F39814; color: white; } 
    #selectable { list-style-type: none; margin: 0; padding: 0; width: 60%; } 
    #selectable li { margin: 3px; padding: 0.4em; font-size: 1.4em; height: 18px; } 
</style> 
<script type="text/javascript"> 
    $(function() { 
     $("#selectable").bind("mousedown", function(e) { 
      e.metaKey = true; 
     }).selectable({ 
      stop: function() { 
       var result = $("#select-result").empty(); 
       $(".ui-selected", this).each(function() { 
        var index = $("#selectable li").index(this); 
        result.append(" #" + (index + 1)); 
       }); 
      } 
     }); 
    }); 
</script> 

<p id="feedback"> 
    <span>You've selected:</span> <span id="select-result">none</span>. 
</p> 

<ol 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> 
</ol> 
関連する問題