2013-10-12 66 views
0

我對一些可拖動的項目使用gridster gridster.net。這些項目也是可點擊的。當點擊時,它會展開。但問題是,當我拖動一個項目時,它也會觸發一個單擊事件,並且該項目在放下後展開。我怎樣才能防止呢?使用jquery gridster阻止點擊事件

這裏是我的jQuery代碼示例:

$(document).on('click touchend', '.gridster li.gs-closed p', function() { 
    var clickedItem = $(this); 
    var parent = clickedItem.parent('li'); 
    gridster.resize_widget(parent, 1,4); 
    parent.removeClass('gs-closed').addClass('gs-opened'); 
}); 

$(document).on('dblclick touchend', '.gridster li.gs-opened p', function() { 
    var clickedItem = $(this); 
    var parent = clickedItem.parent('li'); 
    gridster.resize_widget(parent, 1, 1); 
    parent.removeClass('gs-opened').addClass('gs-closed'); 
}); 
+0

[gridster的可能重複,不要調用div的點擊操作](http:// stackover flow.com/questions/14301026/gridster-do-not-invoke-the-click-action-for-the-div) –

回答