jQuery UI dialog - how to make it not closable?
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 tha开发者_StackOverflow社区t 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
Ying, just pass a callback function to beforeclose
:
$("#loading").dialog({
beforeclose: function(){ return false }
// other options here
});
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;
}
I think Ying is on the right track but it turns out that the .classForMyDialog
(assuming it's the div with dialog content) doesn't have the icon as a child so it didn't work.
I had success with:
$("#myDialogDivID").parent().find(".ui-dialog-titlebar-close").hide()
The parent selects the dialog envelop div
and then we can find and hide the close icon.
I also take this opportunity to highlight the comment to set:
closeOnEscape: false
How I got about it thanks to Ying and Doug
Class:
.myDialog .ui-icon{
display:none !important;
}
Jquery:
$(".ajaxloader").dialog({
modal:true,
resizable:false,
dialogClass:'myDialog'
});
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/
精彩评论