From what I understand, in jquery, when a method requires a function as an argument, you cannot just call a predefined function as follows:
$('#target').click(myFunction());
... because "myFunction ()" will be parsed and replaced with the value returned by the function ... which is no longer a function. You must put the definition of the entire function in an anonymous function:
$('#target').click(function() {
alert('Handler for .click() called.');
});
... so is there a way to just call a function where it is needed as an argument?
source
share