Close modal window

Posted by Eyal on Stack Overflow See other posts from Stack Overflow or by Eyal
Published on 2012-12-05T11:02:56Z Indexed on 2012/12/05 11:03 UTC
Read the original article Hit count: 135

Filed under:

I have page with products. When adding a product to the shopping cart a modal window is fired up for confirmation - this can take up to 2 seconds.

I want to show another modal window just before the confirmation modal to show "loading..."

my problem is that I don't know how to close the "loading..." modal.

This the code which fired up the confirmation modal:

 $(document).ready(function () {
        var $dialog = $('<div style="background-color:red"></div>')
        .html('<h1>loading...</h1>')
        .dialog({
            autoOpen: false,
            title: 'loading...'
        });
        $('.AddToCartButton').click(function () {
            $dialog.dialog('open');
        });        

    });

On the 'confirmation' modal I am trying to close the the 'loading..." modal with this code:

<script type="text/javascript">
    $('#AddToCartButton').dialog('close');    
</script>

Please help. Thanks.

© Stack Overflow or respective owner

Related posts about jQuery