简体   繁体   中英

Removing the close button (the X in the top-right corner) - in dialog box created using dojo?

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?

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM