Jquery 如果使用getscript加载,如何使tablesorter工作。

Jquery 如果使用getscript加载,如何使tablesorter工作。,jquery,tablesorter,Jquery,Tablesorter,我正在使用jquery.getscript加载tablesorter WOI_.loadeddatatables = false; $.getScript("//cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.22.1/js/jquery.tablesorter.min.js").done(function(script, textStatus ){ console.log("text status " + textStat

我正在使用jquery.getscript加载tablesorter

WOI_.loadeddatatables = false;

$.getScript("//cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.22.1/js/jquery.tablesorter.min.js").done(function(script, textStatus ){   
    console.log("text status " + textStatus);
    WOI_.loadeddatatables = true;

    }).fail(function(jqxhr, settings, exception){

      console.log(jqxhr);

});
稍后,我会编写一些代码,检查WOI_u.loadeddatatables是否为true,如果为true,则调用sorttable

WOI_.functions.sorttable = function(el){
     console.log(el);

     el.tablesorter(); 
}

if(WOI_.loadeddatatables){
     WOI_.functions.sorttable($("#userwidgetstats"));
}
我的文本状态是success,因此脚本已经加载,如果我在参考资料面板中检查它,我也可以看到它已经加载

log(el)返回一个长度为1的jquery元素

该表的结构似乎正是tablesorter所寻找的——一个thead和一个tbody,一个带有tr和多个th元素的thead,一个带有多个tr的tbody。无论如何,如果表结构有问题,我希望它会引发一些其他错误


所以实际上,tablesorter似乎不喜欢由getscript加载。是这样吗

jQuery是先加载的吗?什么是可排序的
功能?另外,将
debug:true
添加到tablesorter的初始化代码中,以查看是否存在任何问题。谢谢,我将尝试debug:true,没有可排序的。有WOI_.functions.sorttable,它只是在传入的元素上调用tablesorter。jquery首先加载。debug:true没有做任何事情,我猜是因为tablesorter从未作为传递debug的函数添加到jquery中:true不会给我任何信息。:)无论如何,我认为我在使用此功能方面浪费了太多时间,转而使用此解决方案: