Question

I am working with a .Net 1.1 web application. There is a Save button that, when clicked, will pop up the Javascript confirm box. Once the user clicks OK a long running process is kicked off. We would like to show a busy indicator when the user clicks the OK button of the confirm dialog. Can this be done?

Was it helpful?

Solution

if(confirm("Are you sure you would like to save?")){
    alert("Loading") //Replace with what you want to do  
}

OTHER TIPS

The button on an alert() dialog is not scriptable. You need to find where in the code the alert() is called and patch in to the code just after this.

What you want to do is pretty simple. A confirm('Text') returns true or false after the user makes their selection. All you need to do is on true show a busy indication.

Here is what you're looking for http://jsfiddle.net/Akkuma/C6ZZf/

$('#save').on('click', function () {
    var shouldSave = confirm('Make your choice');

    if(shouldSave) {
        alert('Do saving');
    }
    else {   
        alert('Not saving'); 
    }
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top