Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
363 views
in Technique[技术] by (71.8m points)

tablesorter - "e.handler.apply" is not a function in jquery table sorter

In one of my application I am using JQUERY tablesorter.But while sorting with any of the cloumns I am getting below error. Any idea why this is happening.

Error : "e.handler.apply" is not function in Jquery.js

My code to use table sorter is as below.

$(".tablesorter")
.tablesorter(
    {
        headers: { 0: { sorter: false}},
        widgets: ['zebra'],
        fixedHeight: false
    })
.tablesorterPager({
  container: $(".pager")
    });

$("#sortHeader").click(

    $(".tablesorter")
    .bind("sortStart",function(e, table) 
        {
            $('.tablesorter').trigger('pageSet',0);

        })

);

But If I am commenting the code which starts from "$("#sortHeader").click" then it is working fine. But I need that portion of code to meet my requirement.

Any thoughts on this.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You are missing a function() callback block of click:

$("#sortHeader").click(function(){ // <-----you need to have a callback function.
    $(".tablesorter").bind("sortStart",function(e, table){
        $('.tablesorter').trigger('pageSet',0);
    });
}); // <---do a proper closing.

Issue in your code:

When you do :

$("#sortHeader").click(

without a callback function that will always gives you error in the jQuery library as you got to know Error : "e.handler.apply" is not function in Jquery.js

Because the way .click() method is written it needs a callback function to do something whenever you fire this event. so in your code jQuery thinks that whatever written in the (...here...) is a callback to the fired click event and it fails to apply that callback.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...