本文介绍了使用jQuery tablesorter,我无法让它为我的表做工作。我哪里错了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿伙计们所以我正在尝试使用jQuery插件表分拣机(tablesorter.com)。我根据他们的演示做了一个测试页面,它没有问题。但是现在我正试图将它实现到我的网站中,我不能让它为我做任何事情。这是我的代码。
Hey guys so I am trying to use the jQuery plugin table sorter (tablesorter.com). I made a test page based off their demo and it worked no problem. However now I am trying to implement it into my website and I can't get it to do anything for me. here is my code.
HTML / PHP
HTML/PHP
<table border="0" cellpadding="0" cellspacing="0" id="orgTable" class="tablesorter">
<thead>
<tr>
<th><?=$languageDB->berkGet("object_organization_name");?></th>
<th><?=$languageDB->berkGet("object_organization_description");?></th>
<th><?=$languageDB->berkGet("object_organization_system_name");?></th>
<th><?=$languageDB->berkGet("object_organization_status");?></th>
<th><?=$languageDB->berkGet("object_organization_client");?></th>
<th><?=$languageDB->berkGet("object_organization_actions");?></th>
</tr>
</thead>
<?foreach ($organizations as $organizationObj) {
foreach ($organizationObj as $curOrg) {
if($curOrg->get("name") == "System"){
//Hide the System organization from vCloud
continue;
}?>
<tbody>
<tr>
<td><?=$curOrg->get("name");?></td>
<td><?=$curOrg->get("description")===""?"None":$curOrg->get("description")?></td>
<td><?=$curOrg->get("systemName")?></td>
<td><?=$status[$curOrg->get('status')];?></td>
<td id="client<?=$curOrg->get('id');?>">
<?if($curOrg->get("clientId")==0){ ?>
<button class="btn btn-tiny btn-reverse associate" data-uid="<?=$curOrg->get('id');?>"><?=$languageDB->berkGet("action_associate");?></button>
<?} else{
$client=new client($curOrg->get("clientId"));?>
<?=$client->get("companyName");?>
<?}?>
</td>
<td><a href="/organizationDetails.php?id=<?=$curOrg->get('id');?>" class="btn btn-tiny"><i class="fa fa-info-circle"></i></a>
<?if($curOrg->get("clientId")>0){ ?>
<button class="btn btn-danger btn-tiny" id="remove" data-uid="<?=$curOrg->get('id');?>" data-name="<?=$curOrg->get('name');?>"><i class="fa fa-trash"></i> </button>
<?}?>
</tr>
</tbody>
<?}
}?>
</table>
Javascript
Javascript
<script type="text/javascript" src="js/jquery-1.9.1.js" />
<script type="text/javascript" src="js/jquery.tablesorter.js" />
<script type="text/javascript">
$(document).ready(function()
{
$("#orgTable").tablesorter();
}
);
</script>
推荐答案
放入< tbody> ;
在for循环之外。
Put your <tbody>
outside the for loops.
...
</thead>
<tbody>
<?foreach ($organizations as $organizationObj) {
foreach ($organizationObj as $curOrg) {
if($curOrg->get("name") == "System"){
//Hide the System organization from vCloud
continue;
}?>
<tr>
<td><?=$curOrg->get("name");?></td>
<td><?=$curOrg->get("description")===""?"None":$curOrg->get("description")?></td>
<td><?=$curOrg->get("systemName")?></td>
<td><?=$status[$curOrg->get('status')];?></td>
<td id="client<?=$curOrg->get('id');?>">
<?if($curOrg->get("clientId")==0){ ?>
<button class="btn btn-tiny btn-reverse associate" data-uid="<?=$curOrg->get('id');?>"><?=$languageDB->berkGet("action_associate");?></button>
<?} else{
$client=new client($curOrg->get("clientId"));?>
<?=$client->get("companyName");?>
<?}?>
</td>
<td><a href="/organizationDetails.php?id=<?=$curOrg->get('id');?>" class="btn btn-tiny"><i class="fa fa-info-circle"></i></a>
<?if($curOrg->get("clientId")>0){ ?>
<button class="btn btn-danger btn-tiny" id="remove" data-uid="<?=$curOrg->get('id');?>" data-name="<?=$curOrg->get('name');?>"><i class="fa fa-trash"></i> </button>
<?}?>
</tr>
<?}
}?>
</tbody>
</table>
这篇关于使用jQuery tablesorter,我无法让它为我的表做工作。我哪里错了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!