Tablesorter: can not click pulldown in header

别来无恙 提交于 2019-12-11 09:27:58

问题


In the head I have a static pulldown than when changed reloads the page with the data in the column selected in the pulldown. If I turn on tablesorter, clicking sorts the table but renders the pulldown inaccessible. I have done the ccs to show the arrows, so I can click next to the pulldown to sort.

So what I want to achieve is: Clicking next to the pulldown in the head tag should sort the table. Clicking the pulldown enables the pulldown (and does the reload).

PS jquery version 1.7.1 (can't update!)

The basic code:

<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>

... which is not working. Based on the suggesting below I now am a step closer as now it stops sorting when clicking on the pulldown, but it is still not opening it.


回答1:


Use the following code... bind to "mouseup" and prevent propagation to stop the click from sorting the column (demo):

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



回答2:


This seems to work:

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


来源:https://stackoverflow.com/questions/25621660/tablesorter-can-not-click-pulldown-in-header

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!