I'm trying to perform a specific action when I close a jQuery UI dialog. Here's a simplified version of my code:
$('a.open-trigger').click(function(){
var test = 'hello';
$('#dialog').dialog({
bgiframe: true,
dialogClass: 'change',
resizable: false,
draggable: false,
modal: true,
height: 334,
width: 450,
autoOpen: false,
show: 'fade'
});
$('#dialog').dialog('open');
$('a.close-trigger').click(function(){
alert(test);
$('#dialog').dialog('close');
});
});
The first time I close the dialog, I get the expected alert with the word "hello". If I open the dialog a second time, and close it, I get the "hello" alert twice. If I open and close it a third time, I get three alerts, and so on.
Why are these alerts duplicating themselves? I would want to the alert to only show up once on close, no matter how many times I open/close the dialog.
Thanks! Simon