Is there a way to limit to the number of times a dialog box is triggered to appear until the page is reloaded? Specifically, I am using the jQuery UI Dialog Widget. I was hoping there was some way of feeding this into the options of the widget - I imagine it would look something like
// div#notice is the name of the dialog element,
// with style="display:none" by default
$("#notice").dialog({
dialogClass: "noticeDialog",
buttons: [{
text: "OK",
click: function() {
$(this).dialog("close");
}
}],
repeat: 1 // A Dialog option equivalent to this does not exist to
// my knowledge
}
The only way I can think of achieving this is for the dialog box to .remove() itself from the DOM inside the 'close' option callback function. Something like:
$(".selector").dialog({
close: function() {
$(#"dialogBox").remove();
}
});
I have a feeling this will not work as hoped, however. What better options are there? If there is a way to set a timeout on the dialog box, that would also be helpful and/or accomplish a similar effect.
Do it in the code that triggers the dialog. First, initialize a counter:
Then in the code that displays the dialog, increment and test it: