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.
As others have said, you must provide a function.
One way is to take the existing code in question, and wrap it in an anonymous function:
The other way is to give this function a name. If you've given your function a name and are still having trouble, ensure that you have passed the function name without parentheses.
I incorrectly placed the third parameter of the Underscore.js
debounce
function, which somehow caused the same error.Bad:
Good:
You are missing a
function()
callback block ofclick
:Issue in your code:
When you do :
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 firedclick
event and it fails to apply that callback.As it stands, what you're trying to do is to pass a parameter to jQuery's
click
function. More specifically, the return value of your call tobind
, which just returns a jQuery object, which is not a function, henceapply
is undefined on it and this results in the error that you're getting.You need to wrap what you wrote inside
click()
in a function declaration: