mardi 5 mai 2015

javascript jQuery tablesorter fails to initalize - $this scope?

I have a tablesorter table that uses the following script to load:

   function setupTablesorter() {
    $(".tablesorter").each(function (i, e) {
      var myHeaders = {}
      $(this).find('th.nosort').each(function (i, e) {
        myHeaders[$(this).index()] = {sorter : false };
      });
      $(this).tablesorter({widgets: ['zebra'], headers: myHeaders });
    });
  }

It calls on document ready:

 $(document).ready(function() { setupTablesorter() });

This works with jQuery 1.8.1 in rails3 without the asset pipeline, but now is failing with the latest jQuery or jQuery 1.8.1 with the asset pipeline on the "$(this).tablesorter({widgets: ['zebra'], headers: myHeaders });" line. Seems like $(this).tablesorter is a different type of object now?

Uncaught TypeError: undefined is not a function

Aucun commentaire:

Enregistrer un commentaire