Shaggy
Shaggy

Reputation: 5790

Dialog close automatically with timer

I have used jquery dialog i want it to close automatically after say 2 seconds..How can i acheieve this ? i tried fadeout function but nothing works...

//Below Code will get executed if successful operation does not happen...below code is included in "Save" button of another dialog

 window.parent.$('#divDialog').dialog('close');
 window.parent.$('#divDialog').dialog('destroy');
 window.parent.$('#divDialog').html(sMessage);
 window.parent.$('#divDialog').attr('title', (((parseInt(response) != NaN)) ? 'Error' : 'Notice'));
 window.parent.$('#divDialog').dialog({ show: "blind", modal: true, dialogClass: 'alert', zIndex: 99999 });

Upvotes: 3

Views: 3428

Answers (2)

chrisfrancis27
chrisfrancis27

Reputation: 4536

You're looking for the Javascript (not specifically jQuery) setTimeout() function - it executes a piece of code after a specified number of milliseconds.

Upvotes: 2

Mark Pieszak - Trilon.io
Mark Pieszak - Trilon.io

Reputation: 66971

setTimeout( function () { 
        window.parent.$('#divDialog').dialog('close'); 
    }, 2000 // milliseconds delay
);

Upvotes: 5

Related Questions