Welcome Guest, Not a member yet? Register   Sign In
jQuery table sorter is not working
#1

[eluser]zsela[/eluser]
Hi everybody!

I would like to have your help in a question:
I try to use jQuery Table Sorter on my site.
Unfortunately it doesn't sort the columns of my table, I always get this error:
Quote:$("#usertable").tablesorter is not a function

I include the .js files in the header view.
I call the function at the beginning of the manage_users view:

Code:
$(document).ready(function() {
$("#usertable").tablesorter();
}
);

And finally I fill up the table with data later in the manage_users view:

Code:
echo '<table id="usertable" class="tablesorter">';
      echo '<thead>';
       echo '<tr><th>Felhasználónév</th>';
       echo '<th>Név</th>';
       echo '<th class="centerAlign">Szerkesztés</th>';
       echo '<th class="centerAlign">Törlés</th></tr>';
      echo '</thead>';
      echo '<tbody>';
      
      $i = 1;
      foreach ($all_user->result() as $row) {
          
       $class = ($i % 2 == 0) ? "userManageEvenRow" : "userManageOddRow";
      
       echo '<tr class="' . $class . '">';
          echo '<td class="leftManageUser">';
           echo anchor('user/profile/' . $row->user_name, $row->user_name, array('title' => $row->user_name . ' adatlapja'));
          echo '</td>';
          echo '<td class="centerManageUser">' . $row->surname . ' ' . $row->firstname . '</td>';
          echo '<td class="rightManageUser">';
           echo anchor('admin/edit_user/' . $row->ID, '<img src="' . base_url() . 'images/edit.png" border="0">',
               array('title' => $row->user_name . ' adatlapjának szerkesztése'));
          echo '</td>';
          echo '<td class="rightManageUser">';
           if ($row->ID != $this->session->userdata('ID')) {
            echo anchor('admin/delete_user/' . $row->ID, '<img src="' . base_url() . 'images/delete.png" border="0">',
            array('title' => $row->user_name . ' fiókjának törlése'));
           }
          echo '</td>';
          echo '</tr>';
          $i++;
          
      }
      
      echo '</tbody>';
      echo '</table><br />';

I can see the table, but no sorting is possible.

Thanks for your answers in advance!
#2

[eluser]Aken[/eluser]
That error means it does not recognize that function, which means you didn't load the Javascript files properly.
#3

[eluser]CroNiX[/eluser]
Yep, check firebug to see if you are getting a 404 while loading your js file. Also, make sure you are loading jquery before loading any jquery plugins.
#4

[eluser]zsela[/eluser]
You were right, the order was faulty: I loaded the plugin before jquery.
It is such a primitive error, sorry to bother you with that.

Thanks for the quick replies!




Theme © iAndrew 2016 - Forum software by © MyBB