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();
    }
}
有帮助吗?

解决方案

Try this:

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

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top