Question

I'm trying to hide a spinner which always sits inside of a div with an id of "Loading". This is working fine however I've added a callback function which, in this case is simply an alert() however the alert() appears to fire before the fadeOut() has completed leaving me with the spinner's translucent background panel still visible behind the alert.

Any idea?

// Hide the spinner. 
function deactivate(callbackFn) {
    console.log('spinner deactivated');
    $("#Loading").fadeOut(removeSpinnerTag(callbackFn));
}

// Removes the spinner tag dynamically added to the DOM by the spinner.activate() method. 
function removeSpinnerTag(callbackFn) {
    $("#Loading div.spinner").remove();
    if (typeof (callbackFn) == 'function') {
        callbackFn();
    }
}
Était-ce utile?

La solution

Try this:

$("#Loading").fadeOut(function() { removeSpinnerTag(callbackFn) });

You were executing removeSpinnerTag() instead of passing a reference to the function.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top