Reputation: 2350
I'm having some trouble getting the close button on my dialog box to work. I followed an example I found, but mine won't close. What am I doing wrong?
$(function() {
$('#message').dialog({
autoOpen: false,
bgiframe: true,
modal: true,
buttons: {
'Okay': function() {
document.location =
'http://www.google.com';
},
'Cancel': function() {
('#message').dialog('close');
}
}
});
$('button').click(function() {
$('#message').dialog('open');
});
});
Upvotes: 2
Views: 9782
Reputation: 2350
Since my click event is referring to a general button, hitting the cancel button essentially opened the dialog again. I gave the button an id and referenced that.
Upvotes: 1
Reputation: 1857
It's the line:
'Cancel': function() { ('#message').dialog('close'); }
Change it to:
'Cancel': function() { $(this).dialog('close'); }
Upvotes: 2