amitben amitben - 3 months ago 46
jQuery Question

jqueryui switchClass callback

i'm having a problem running a function after a jquery ui switchclass effect is completed.

looking into the manual it describes that
.switchClass( removeClassName, addClassName [, duration ] [, easing ] [, complete ] )

but when trying to run a:


with a

function runAfterComplete(){
console.log("switchclass completed");

it runs it before it is completed.


You need to pass a function reference(runAfterComplete) as the callback, in your case you are invoking(() at the end) the runAfterComplete function and the value returned from it(undefined) as the callback to the switchClass method