如果这是一个重复的问题,我很抱歉,但是我花了几个小时去寻找一个没有成功的解决方案。也很抱歉英语不好,不是我的母语。:(
这是我的问题:
我有一个由Spring3.0.5处理的web应用程序。我的一个JSP文件从数据库中检索数据并将其放入表中,这很好。我正在尝试使用jquery插件表来对表中的字段进行排序,这对我来说也很好,所以我尝试使用寻呼机的副词,这就是我的童话故事出现的时候。
我在表的末尾定义了一个带有"id=anyname"的表单,就像tablesorter web中的文档所说的那样,并在脚本中调用它,但它不起作用。
在这里,我留下了JSP文件:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="<c:url value="/resources/css/style.css"/>" />
<link rel="stylesheet" type="text/css" href="<c:url value="/resources/css/jquery.tablesorter.pager.css"/>" />
<script type="text/javascript" src="<c:url value="/resources/js/jquery-1.8.2.js" />"></script>
<script type="text/javascript" src="<c:url value="/resources/js/jquery-ui-1.9.1.custom.js" />"></script>
<script type="text/javascript" src="<c:url value="/resources/js/jquery-ui-1.9.1.custom.min.js" />"></script>
<script type="text/javascript" src="<c:url value="/resources/js/jquery.tablesorter.pager.js" />"></script>
<script type="text/javascript" src="<c:url value="/resources/js/jquery.tablesorter.js" />"></script>
<script>
$(document).ready(function() {
$("#consulta")
.tablesorter({
headers: { 0: { sorter: false }, 1: { sorter: false }, 6: { sorter: false }},
sortList: [[2, 0], [0, 0]],
widthFixed: true,
widgets: ['zebra']})
.tablesorterPager({container: $("#pager")});
});
</script>
</head>
<body>
/*
*
*
*
*/
<table id="consulta" class="tablesorter">
<thead>
<tr>
<th>Código</th>
<th>Especialidad</th>
<th>Asunto</th>
<th>Fecha</th>
<th>Ciclo</th>
<th>Estado</th>
<th>Opciones</th>
</tr>
</thead>
<tbody>
<c:forEach items="${consultaSol}" var="solic">
<c:url var="verUrl" value="/manage/mgmtSol/detalle?id=${solic.id}" />
<tr>
<td><c:out value="${solic.codigo}" /></td>
<td><c:out value="${solic.especialidad}" /></td>
<td><c:out value="${solic.asunto}" /></td>
<td><c:out value="${solic.fecha}" /></td>
<td><c:out value="${solic.ciclo}" /></td>
<c:if test="${solic.estado == 0 }">
<td>No atendido</td>
</c:if>
<c:if test="${solic.estado == 1 }">
<td>Atendido</td>
</c:if>
<c:if test="${solic.estado == 2 }">
<td>Resuelto</td>
</c:if>
<td><a href="${verUrl}">Ver Detalle</a></td>
</tr>
</c:forEach>
</tbody>
</table>
<div id="pager" class="pager">
<form>
<img src="<c:url value="/resources/imagenes/first.png" />" class="first"/>
<img src="<c:url value="/resources/imagenes/prev.png" />" class="prev"/>
<input type="text" class="pagedisplay" readonly="readonly"/>
<img src="<c:url value="/resources/imagenes/next.png" />" class="next"/>
<img src="<c:url value="/resources/imagenes/last.png" />" class="last"/>
<select class="pagesize">
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
</select>
</form>
</div>
</body>
</html>我不知道我做错了什么,就像我之前说过的,表很好,但寻呼机选项不工作。顺便说一下,我使用了jquery 1.9.1,并将其更改为1.8.2版本,但它不起作用。
此外,在运行应用程序时,Chrome developer工具显示了一个错误:
Uncaught TypeError: Cannot call method 'addClass' of undefined但我不明白,它来自jquery-1.8.2.js文件。
请救救我!
提前谢谢。
发布于 2013-05-20 14:01:56
感谢穆蒂的回应。问题是在jquery版本中,Tablesorterv2.0.5似乎导致了jQuery 1.9+中的错误。因此,我将jquery版本更改为1.8.3,它运行得很好。
再次感谢莫蒂给我那个信息。欢迎光临。
https://stackoverflow.com/questions/16597198
复制相似问题