I am using Ruby on Rails and have a table that I am trying to sort. The tablesorter jquery plugin and it is properly loaded in my files. I have jquery called in front of it at well. I have this code in my javascript.
$(document).ready(function()
{
$("#myTable").tablesorter({widgets: ['zebra']});
$("#business").tablesorter({sortList: [[0,0], [1,0]]});
}
);
I have 2 tables. I have my table which is static just to see if the code was working right. And it works just find. I can sort by clicking on any of the headers.
<table id="myTable">
<thead>
<tr>
<th>Last Name</th>
<th>First Name</th>
<th>Email</th>
<th>Due</th>
<th>Web Site</th>
</tr>
</thead>
<tbody>
<tr>
<td>Smith</td>
<td>John</td>
<td>[email protected]</td>
<td>$50.00</td>
<td>http://www.jsmith.com</td>
</tr>
<tr>
<td>Bach</td>
<td>Frank</td>
<td>[email protected]</td>
<td>$50.00</td>
<td>http://www.frank.com</td>
</tr>
<tr>
<td>Doe</td>
<td>Jason</td>
<td>[email protected]</td>
<td>$100.00</td>
<td>http://www.jdoe.com</td>
</tr>
<tr>
<td>Conway</td>
<td>Tim</td>
<td>[email protected]</td>
<td>$50.00</td>
<td>http://www.timconway.com</td>
</tr>
</tbody>
</table>
But I also have my other table which is pulling dynamically from a database. Which doesn't work at all and does nothing at all when I click on the headers.
<table width="650" cellpadding="6" cellspacing="0" id="business">
<thead>
<tr>
<th>Business Name</th>
<th>Address</th>
<th>Category</th>
<th>Description</th>
</tr>
</thead>
<% @businesses.each do |business|if !business.approved %>
<tbody>
<tr>
<td><a class="Contact<%=h business.id %>" href="#"><%=h business.name %></a></td>
<td><%=h business.address %></td>
<td><%=h business.business_category.name %></td>
<td><%=h business.description %></td>
</tr>
</tbody>
<% end %>
<% end %>
</table>
Any Help would be great.