简体   繁体   中英

Using JQuery table sorter in Struts2

My problem is mainly getting the tablesorter from jquery to operate correctly. I believe the issue stems from the fact that I use an iterator to display my table information - which is necessary in the way I have designed my struts2 pages.

To start I have placed the jquery-1.11.1.min.js file within my WEB-INF/lib folder. I felt like this was a convenient place to put it. Therefore my tags in my jsp page look like:

 <head>
      <script type="text/javascript" src="/My_Project/WebContent/WEB-INF/lib/jquery-1.11.1.min.js"></script>
      <script type="text/javascript" src="/My_Project/WebContent/WEB-INF/lib/jquery-1.11.1.min.tablesorter.js"></script>
      <script type="text/javascript">
         $(document).ready(function() {
            $("#table").tablesorter();
       });
      </script>
 </head>

then within my body I have my table which looks like:

 <table id="table" class="tablesorter">
      <thead>
           <tr>
                <th>column</th>
                <th>column</th>
           </tr>
      </thead>
    <tbody>
        <s:iterator status="stat" value="listTable">
            <TR>
                <TD><s:property value="%{row1}" /></td>
                <TD><s:property value="%{row2}" /></td>
            </TR>
        </s:iterator>
    </tbody>
</table>

My question is, what am I missing? Is the iterator why I can't get the table sorter to work? Is it my formatting?

Any help information or better yet examples would be greatly appreciated.

follow this jsFiddle. hjsfiddle.net/Mottie/4mVfu/1/

You will find what you are missing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM