Tuesday, January 26, 2010

Re: [jQuery] Re: tablesorter line numbers

It'd be cleaner to have this a widget. For the direct matter, give your row a class, remove rows of that class, then append it again as part of the function.

aquaone


On Mon, Jan 25, 2010 at 19:59, jay <jjpricer@gmail.com> wrote:
Is there any way to get the following code to refresh after every
sort?

The <  $("#myTable").each(function(){   > numbers it, and if I replace
it with <  $("#myTable").bind("sortEnd",function(){  > it just adds a
new numbered row after every sort (three sorts gets you three columns
of numbers).

--------------------------------------
 $(document).ready(function(){
 $("#myTable").each(function(){
   if($(this).is('table')){
     $('thead th:first-child, thead td:first-child', this).each
(function(){
       if($(this).is('td'))
         $(this).before('<td>#</td>');
       else if($(this).is('th'))
         $(this).before('<th>Item</th>');
     });
     $('tbody td:first-child', this).each(function(i){
       $(this).before('<td>'+(i+1)+'</td>');
     });
   }
 });

No comments: