amitben amitben - 1 year ago 114
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.

Answer Source

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