Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable 'X' button in top-right of Dialog [duplicate]

Possible Duplicate:
Remove close button on jQueryUI Dialog?

I'm trying to make a dialog that requires a user to agree to terms before continuing, and don't want to allow the user to just click the 'X' in the top right corner of the dialog to close. I'd like to require that the user click 'I agree'.

Is there any way to disable the 'X' in the dialog?

Clarification: I'm just using the standard jQuery UI dialog: $.dialog().

like image 911
BAHDev Avatar asked Jan 11 '10 15:01

BAHDev


2 Answers

I found this on another post, hopes it helps, it worked for me:

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

This is the link:

How to remove close button on the jQuery UI dialog?

like image 94
foxvor Avatar answered Sep 30 '22 23:09

foxvor


I'm assuming you are using jQuery UI.

If so, attach a beforeClose event handler and return false from it if the Agree button hasn't been clicked. You can also use CSS to set the X button to {display: none}

var agreed = false; //has to be global $("something").dialog({     buttons: {         'Apply': function () {             agreed = true;             $(this).dialog("close");         }     },     beforeClose: function () {         return agreed;     } }); 
like image 43
Chetan S Avatar answered Sep 30 '22 21:09

Chetan S