Reputation: 339
How to remove the close button (the X in the top-right corner) on a dialog box created using dojo? I came across dlg.closeButtonNode.style.display='none'; but it didn't work. Is there any other way around?
Upvotes: 1
Views: 3619
Reputation: 28638
I'm guessing that doesn't work because your dialog instance isn't assign to a var named "dlg" but i can't be sure because you didn't post any code. Otherwise this should work. But there is an easier way to accomplish this, just by using CSS.
.dijitDialogCloseIcon {
display: none;
}
That's all assuming you can't change your dialog instance otherwise you really should use the "closable" property of the dijit itself to disable closing of the dialog. Edit: As Ken in the comments pointed out, it's the preferred way since it also disables the handling of the escapekey. Examples:
Programmatic:
require(["dijit/Dialog", "dojo/domReady!"], function(Dialog){
myDialog = new Dialog({
title: "My Dialog",
content: "Test content.",
style: "width: 300px",
closable: false // here
});
});
Declaritive:
<div data-dojo-type="dijit/Dialog" data-dojo-id="myDialog" data-dojo-props="closable:false"></div>
Upvotes: 4