2014-09-02 24 views
1

在頭部我有一個靜態下拉比當更改重新加載頁面時在下拉列表中選擇的列中的數據。 如果我打開tablesorter,單擊排序表,但呈現下拉菜單不可訪問。 我已經完成了ccs來顯示箭頭,所以我可以點擊旁邊的下拉菜單進行排序。Tablesorter:無法點擊標頭中的下拉菜單

所以我想實現的是: 單擊head標籤下拉菜單旁邊的應該對錶格排序。 單擊下拉菜單可啓用下拉(並重新加載)。

PS的jQuery 1.7.1版本(不能更新!)

的基本代碼:

<style> 
    table.tablesorter thead tr div span { 
     padding: 0px 8px; 
     cursor: pointer; 
    } 
</style> 
<table class="tablesorter"> 
<thead> 
    <tr> 
     <th class="header"> 
      <div> 
       <span></span> 
       Kolommen: 
       <select>...</select> 
      </div> 
     </th> 
     ... 
<script> 
<!-- 
    $(function() { 
     $("table.tablesorter").tablesorter(); 
     $("select").on("click", function (e) { 
      e.stopPropagation(); 
      // do something 
     }); 
    }); 
//--> 
</script> 

...這是行不通的。根據下面的建議,我現在離現在更近了一步,現在它在點擊下拉菜單時停止排序,但仍然無法打開它。

回答

0

使用下面的代碼...綁定到「鼠標鬆開」,並防止傳播從排序列(demo)停止點擊:

$('select').on('mouseup', function (e) { 
    e.stopPropagation(); 
    // do something 
}); 
+0

謝謝,但不完全。向前邁進了一步:用代碼更新了問題以便更好地理解。 – 2014-09-03 10:22:35

+1

我應該在這裏添加一個註釋,我的[fork of tablesorter](http://mottie.github.io/tablesorter/docs/)需要「mouseup」,但是[原始tablesorter]需要「點擊」( http://tablesorter.com/docs/)...我計劃儘快重命名我的叉子以避免混淆。 – Mottie 2014-09-04 12:50:55

0

這似乎工作:

$("select").on("mousedown click", function (e) { 
    e.stopPropagation(); 
});