質問

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