views:

38

answers:

2

i have a strange problem with jquery i have this div that shows messages for ajaxified actions and i want the message to go away when after 5 seconds .. it works for the first time.. but when i trigger the action again in the same page the dialog appears but and never get fade out no matter what unless i close it by press the X button .. the code is

    jQuery( "#dialog" ).dialog({
    open: function(event, ui) {
setTimeout(function(){
    jQuery("#dialog").dialog("close");
}, 5000);

    },
hide: "fadeOut"
});

and it's included in a jsp page that include in all ajax pages..what is the problem??

+1  A: 

I got it anyway.. i should remove the dialog div everytime it closed looks dirty work but in get a good result

Mohamed Emad Hegab
jQuery("#dialog").remove();
Mohamed Emad Hegab
+1  A: 

Take a look at this blog entry from nemikor (as stated on the jquery-dialog page)

Every time you call that code snippet, jquery tries to create a new dialog-instance with id dialog. Create that dialog on start up with the autoOpen option set to false and display the dialog by calling dialog('open')

example on jsfiddle

john_doe
yes i got this ..that why i removed the div it created it on close.. but you solution is neat more..thanks man :)
Mohamed Emad Hegab