2013-11-02 53 views
0

我在這裏有一個jsfiddle - http://jsfiddle.net/X8z6B/1/ - 在我選擇的容器中有三個可拖動的框。我可以在兩個框周圍拖出一個矩形並選擇它們,但我無法按住Ctrl鍵並單擊第三個框並將其選中。它似乎是拖動處理程序,因爲它可以正常工作,如果從框中刪除draggable()(在jQuery中註釋掉第35行)。有誰知道如何使用Ctrl-點擊選擇第三個可拖動框?無法將可拖動的元素添加到選定的組

感謝

<div id='container'> 
    <div id="box1" class="box">1</div> 
    <div id="box2" class="box">2</div> 
    <div id="box3" class="box">3</div> 
</div> 

回答

0

的修改按Ctrl +是沒有必要的:

$(function() { 
    $('.box').draggable(); 
    $('#container').selectable({}); 
    $('.box').click(function(){ 
     $(this).addClass("ui-selected"); 
    }); 
}); 

但是,如果一個修改鍵是你的情況很重要:

$(function() { 
    $('.box').draggable(); 
    $('#container').selectable({}); 
    $('.box').click(function (e){ 
     if(e.metaKey){// might be ctrlKey, but metaKey is a Mac compatible 
      $(this).addClass("ui-selected"); 
     } 
    }); 
}); 
相關問題