2013-05-16 42 views
0

對不起,如果這是一個重複的問題,但我花了幾個小時尋找一個解決方案沒有成功。對於英語不好的人也很抱歉,不是我的母語。 :(尋呼機(Tablesort插件)在春季視圖中不起作用

這是我的問題:

我有一個Web應用程序通過處理春天3.0.5我的一個JSP文件檢索數據庫中的數據,並把它變成一個表,這是workig罰款。 我試圖使用jQuery插件tablesort在表中的字段進行排序,這個工作對我也夠,所以我嘗試使用尋呼機插件,當我的童話故事落在那。

我已經用「id = anyname」定義了一個表單在我桌子的最後,因爲在tableorter網站中的文檔說,並在腳本中調用它,但它不起作用。

這裏我把我的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&oacute;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> 

我不知道我做錯了什麼,作爲一個我以前說過的tablesort工作正常,但尋呼機選項沒有。順便說一句,我使用jQuery 1.9.1並將其更改爲1.8.2版本,但它不起作用。

此外,當我運行應用程序,Chrome開發工具顯示一個錯誤:

Uncaught TypeError: Cannot call method 'addClass' of undefined 

,但我不明白它,它從jQuery的1.8.2.js文件的。

請幫幫我!

在此先感謝。

+1

順便說一句,你的英語其實很好。一些語法上的東西,但它是可讀的,這是重要的! –

+0

如果您使用的是[original tablesorter v2.0.5](http://tablesorter.com/docs/),由於它使用'$ .browser'函數,它會在jQuery 1.9+中導致錯誤......你能嗎修改[此演示](http://jsfiddle.net/eY8uH/474/)向我們展示如何得到該錯誤?謝謝。 – Mottie

+0

感謝您的回覆,也許有一些東西貼在緩存中,但當我將jquery版本更改爲1.8.3時,作爲您的jsfiddle演示,我的項目開始工作得很好。再次感謝。 – Cesar

回答

0

感謝Mootie的迴應。 問題出在jQuery版本中,似乎tablesorter v2.0.5在jQuery 1.9+中導致錯誤。 所以我改變了我的jQuery版本到1.8.3,它工作得很好。

再次感謝Mottie給我的信息。 問候。