Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove close button on the jQuery UI dialog?

How do I remove the close button (the X in the top-right corner) on a dialog box created by jQuery UI?

like image 929
Robert MacLean Avatar asked May 22 '09 07:05

Robert MacLean


People also ask

How to remove close button jQuery dialog?

$("Selector"). dialog({ open: function () { $(". ui-dialog-titlebar-close"). hide(); } });

How to remove close button from popup window in JavaScript?

You cannot hide the close button of a pop-up window. If you want that sort of control, don't use a window. This you can style as you want, and the content you show in window. open you can present to the user in an iframe inside the dialog.

How do I close a dialog box in JavaScript?

Close Dialog when clicking outside of its region in JavaScript Dialog control. By default, dialog can be closed by pressing Esc key and clicking the close icon on the right of dialog header. It can also be closed by clicking outside of the dialog using hide method.


2 Answers

I have found this worked in the end (note the third line overriding the open function which find the button and hides it):

$("#div2").dialog({     closeOnEscape: false,     open: function(event, ui) {         $(".ui-dialog-titlebar-close", ui.dialog || ui).hide();     } }); 

To hide the close button on all dialogs you can use the following CSS too:

.ui-dialog-titlebar-close {     visibility: hidden; } 
like image 158
Robert MacLean Avatar answered Oct 14 '22 08:10

Robert MacLean


Here is another option just using CSS that does not over ride every dialog on the page.

The CSS

.no-close .ui-dialog-titlebar-close {display: none } 

The HTML

<div class="selector" title="No close button">     This is a test without a close button </div> 

The Javascript.

$( ".selector" ).dialog({ dialogClass: 'no-close' }); 

Working Example

like image 28
David Avatar answered Oct 14 '22 08:10

David