我有我通过jQuery的load命令装载的表。在负载功能的回调我启动tablesorter插件。出于某种原因,那么表只按降序排序没有上升。即使怪异,如果我按住shift键,将切换正确ASC和DESC之间?任何想法是怎么回事?
I have a table that I load via a jQuery load command. in the callback of the load function I initiate the tablesorter plugin. For some reason then the table only sorts descending not ascending. Even weirder, if I hold shift it will toggle correctly between asc and desc? Any idea what's going on here?
table.php
table.php
<table id="xyz">
<thead>
<tr>
<th>hi</th>
</tr>
</thead>
<tbody>
<tr>
<td>a</td>
</tr>
<tr>
<td>b</td>
</tr>
<tr>
<td>c</td>
</tr>
</tbody>
</table>
jQuery的
jquery
$("#myDiv").load("table.php", function() {
$("#xyz").tablesorter();
});
如果我不通过AJAX装载表则tablesorter的功能如预期。
if I don't load the table via ajax then the tablesorter functions as expected.
好了,所以我是双重结合像杰森想。
Okay so I was double-binding like Jason thought.
我其实是调用一个类jQuery的负载功能,我有两个div的与我的页面类。因此,它实际上是调用回调函数两次?
I was actually calling jQuery's load function on a class and I had two div's with that class on my page. So it actually was calling the callback function twice?
我认为这是一种怪异的行为的内容被加载到这两个div的是一样的,但它看起来像jQuery不会单独Ajax调用每一个的div的。感谢您的意见!
I think it's kind of weird behaviour as the content being loaded into both divs was the same but it looks like jQuery does a separate ajax call for each of the divs. Thanks for your comments!