I would like for a callback function to fire after a click event. Currently I have the JavaScript
$('#btnSubmit').click(function ()
{
$('#testDiv').hide('slow', onComplete('test'));
});
var onComplete = function (t)
{
$('#hiddenDiv').hide();
alert(t);
}
The callback function is supposed to be fired after the hiding of #testDiv. However, the onComplete function fires first. If I remove the parameters on onComplete and just give it a reference and not invoke it, then the function fires at the right time, but I can't pass parameters to it. How can I pass parameters to onComplete and not have it fire before the div is finished hiding?
fiddle here
$('#testDiv').hide('slow', onComplete);, passing callback function reference rather than executing it.