views:

138

answers:

3

Hi, I'm trying to use the jQuery dialog as a loading screen for ajax. I have it working very well so far but I'd like the loading screen to be not closable. However it seems the UI dialog doesn't have "closable" as an option?

How do you make it non-closable? I tried setting closeText to blank but that didn't do anything. The little 'X' still shows up on the upper right corner.

Don't you think closable should be an option for the dialog widget?

Thanks

+1  A: 

Ying, just pass a callback function to beforeclose:

$("#loading").dialog({
  beforeclose: function(){ return false }
  // other options here
});
Doug Neiner
Right, sorry. That is exactly what I would have suggested had you not found that part on your own. Glad it worked for you! Be sure to mark the answer as accepted (click the grey check). We both get rep points and it helps future people with the same problem know what solution worked for you. Welcome to StackOverflow!
Doug Neiner
Oops, I found an issue with this solution. When I call $("#loading").dialog('close') now it does nothing. I needed that to work so I decided just to hide the "X" via css.
Ying
A: 

Doug, thanks for the quick reply. That disabled close action. However, it did not hide the "X" on the upper right corner. I ended up using css to hide the "X".

/* hide the close x on loading screen */
.classForMyDialog .ui-dialog-titlebar-close {
    display: none;
}
Ying
A: 

For a demonstration of how I used jQueryUI dialog as a loading screen.

http://pure-essence.net/2010/01/29/jqueryui-dialog-as-loading-screen-replace-blockui/

Ying