Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery tablesorter插件-禁用标头内图像的排序_Jquery_Html Table_Tablesorter - Fatal编程技术网

jQuery tablesorter插件-禁用标头内图像的排序

jQuery tablesorter插件-禁用标头内图像的排序,jquery,html-table,tablesorter,Jquery,Html Table,Tablesorter,我有一个很大的表(24列),它使用tablesorter插件,为了节省一些空间,我使用垂直图像来显示标题中的标题 我有一个点击事件附加到一些选定的图像,这将打开第二个表(通过jQuery对话框)旁边的标题被点击。我遇到的问题是,当我单击图像时,tablesorter也在对列进行排序(我不希望发生这种情况),因此我试图找到一种方法以某种方式禁用排序,但仅当我单击标题图像时 任何帮助都将不胜感激 HTML代码: <table class="tablesorter" id="sales">

我有一个很大的表(24列),它使用tablesorter插件,为了节省一些空间,我使用垂直图像来显示标题中的标题

我有一个点击事件附加到一些选定的图像,这将打开第二个表(通过jQuery对话框)旁边的标题被点击。我遇到的问题是,当我单击图像时,tablesorter也在对列进行排序(我不希望发生这种情况),因此我试图找到一种方法以某种方式禁用排序,但仅当我单击标题图像时

任何帮助都将不胜感激

HTML代码:

<table class="tablesorter" id="sales">
<thead>
 <tr>
  <th class="sales header" id="th_1"><img alt="" src="name.png" id="Name" onclick="openHeaderGeneric(this)"></th>
  <th class="sales header" id="th_2"><img alt="" src="date.png" id="Date" onclick="openHeaderGeneric(this)"></th>       
 </tr>
</thead>      
</table>
在定义单击事件之前添加此选项。或者,如果您只想对某些标题禁用它,请使用以下ID:

$('#th_1').unbind('click');
$('#th_2').unbind('click');
或者,如果你想更聪明一些:

jQuery.each($('.header img'), function(i, elem) {
  if ($(elem).data('events') !== undefined && $(elem).data('events').click !== undefined) {
    $(elem).parent().unbind('click');
  }
});

我相信这应该行。

您解除单击绑定的想法是对的。之后我不得不再次调用tablesorter函数。谢谢
$('#th_1').unbind('click');
$('#th_2').unbind('click');
jQuery.each($('.header img'), function(i, elem) {
  if ($(elem).data('events') !== undefined && $(elem).data('events').click !== undefined) {
    $(elem).parent().unbind('click');
  }
});