Bird87 ZA
Bird87 ZA

Reputation: 2160

Jquery Delay not functioning as expected

I have a dialog box that I wish to close after 5 seconds.

I have a delay statement in, but it just closes anyway, without any delay.

Here is the code:

$('#dialog').dialog('option','buttons',[]).html('File tags and info updated successfully.').delay(5000).dialog('close');

Any help with what I'm doing wrong and how to fix it?

Upvotes: 0

Views: 62

Answers (2)

peter
peter

Reputation: 185

There is a plugin called jquery-timing. Use that to time any jQuery stuff you have.

In your case you must only replace "delay" with "wait":

$('#dialog').dialog('option','buttons',[]).html('File tags and info updated successfully.').wait(5000).dialog('close');

Have fun!

Upvotes: 0

Danil Speransky
Danil Speransky

Reputation: 30453

delay function is for animation, it may be used like this:

$('#foo').slideUp(300).delay(800).fadeIn(400);

You should use simple setTimeout:

$('#dialog').dialog('option','buttons',[]).html('File tags and info updated successfully.');

setTimeout(function () {
  $('#dialog').dialog('close');
}, 5000);

Upvotes: 3

Related Questions