views:

339

answers:

3

Hi

When a dialog box pops up there is a "X" in the top right hand corner. I am wondering if there is an option to disable this?

Thanks

A: 

The "X" is placed in an anchor tag with the default class="ui-dialog-titlebar-close ui-corner-all ui-state-focus".

You can set the display to none.

a.ui-dialog-titlebar-close{
  display: none;
}
o.k.w
I use the dialog many times in my site. I only want it in one instance. So I guess I would have to do some jquery selecting and remove it? I thought maybe there was some built in function.
chobo2
Yes, since it is only for one instance, even if there's an option, you still need to code it specifically. As far as I can tell from the documentation, there isn't any option to hide/show the default close (X) button.
o.k.w
+1  A: 

Changing the CSS will affect other dialogs.

I'm using the following in the dialog definition, which is executed when it's opened:

open: function() {
            $(this).parent().children(':first').children('a').remove();
         },
Eduardo
A: 

Alternatively you can pass a 'showclose' logical to the function and let the open method logic decide for you.

    open: function(event, ui) {
      if (!showclose)
        $j(ui).find(".ui-dialog-titlebar-close").hide();
      else
        $j(ui).find(".ui-dialog-titlebar-close").show();
    }

That way you can choose to show it each time you call $.dialog.

SKFox