jQuery: Chaining multiple functions gives Uncaught Typeerror

后端 未结 3 1787
孤城傲影
孤城傲影 2021-01-23 15:26

I\'m attempting to chain multiple function calls in my script, but I keep getting Uncaught TypeError: $(...).tablesorter(...).tablesorterPager is not a function whe

相关标签:
3条回答
  • 2021-01-23 15:42
    jQuery(document).ready(function($){
        var pagerOptions = {
            //object definitions in here
        }; 
    
        $("#transaction").tablesorter({
            //function stuff in here    
        }).tablesorterPager(pagerOptions);
    });
    

    Use this method bottom of the page.

    0 讨论(0)
  • 2021-01-23 15:43

    I think this is causing the error .tablesorterPager(pagerOptions);

    Try with this:

    function InitializeTableSorter() {
       var pagerOptions = {
           //object definitions in here
       }; 
    
       $("#transaction").tablesorter(pagerOptions);
    }
    
    0 讨论(0)
  • 2021-01-23 15:49

    Assuming you have the appropriate plugin files installed (in the appropriate order if order matters)

    Uncaught TypeError: $(...).tablesorter(...).tablesorterPager is not a function

    is usually encountered when there are conflicts between jQuery and other libraries. To stay out of trouble, call $.noConflict() and don't forget to run your jQuery code after the document is ready

    $.noConflict();
    jQuery(document).ready(function($){
      function InitializeTableSorter() {
        var pagerOptions = {
            //object definitions in here
        }; 
    
        $("#transaction").tablesorter({
            //function stuff in here    
        }).tablesorterPager(pagerOptions);
      }
    });
    
    0 讨论(0)
提交回复
热议问题