0

I've got a rather confusing problem with jQuery UI Dialog. The issue is that the default close button of the jQuery dialog is not working as it should! But when I click the side areas of the button, it gets closed. Below is the code used to init the dialog.

$("#divGuestDetails").dialog('open');

Nothing else. I tried binding a click event to the dialog after the init process. The code is below.

$('#divGuestDetails').find('.ui-dialog-titlebar-close').bind('click',function(){
    $('#divGuestDetails').dialog('close');
})

The versions of jquery core and ui is as following.

Jquery core : 1.3.2 Jquery ui : 1.7.2

if this is a know issue please guide me on how to fix it.

<div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" unselectable="on" style="-moz-user-select: none;">
<span class="ui-dialog-title" id="ui-dialog-title-divGuestDetails" unselectable="on" style="-moz-user-select: none;">Guest Details</span>
<a href="#" class="ui-dialog-titlebar-close ui-corner-all" role="button" unselectable="on" style="-moz-user-select: none;"><span class="ui-icon ui-icon-closethick" unselectable="on" style="-moz-user-select: none;">close</span></a>
</div>

Above is the runtime html elements and as I checked ui-dialog-titlebar-close is bound with the default close call. But when I check on the click event, it is actually fired from the span that is inside of the <a> tag. what can I do to fix this problem.

Imesh Chandrasiri
  • 5,558
  • 15
  • 60
  • 103

1 Answers1

0
var guestDetails = $("#divGuestDetails").dialog('open');

guestDetails.dialog('close'); // use this anywher to close it

$('#divGuestDetails').find('.ui-dialog-titlebar-close').bind('click',function(){
    guestDetails.dialog('close');
})
wilsonrufus
  • 449
  • 1
  • 5
  • 14