Non closable dialogbox from Extension Library

时光总嘲笑我的痴心妄想 提交于 2019-12-12 18:16:42

问题


I'm creating a dialogbox from ExtLib and I want to prevent users to press Escape or click on X icon.

I've checked several posts about same implementation but none of them using a Dialogbox from ExtLib.

I was able to hide icon with CSS and I'm trying with dojo.connect to prevent the use of Escape key:

    XSP.addOnLoad(function(){
    dojo.connect(dojo.byId("#{id:dlgMsg}"), "onkeypress", function (evt) {  
        if(evt.keyCode == dojo.keys.ESCAPE) {           
            dojo.stopEvent(evt);
        }
    });
});

Note I'm able to get it working only if I create my dialogbox manually and not from ExtLib; then I can use for example:

dojo.connect(dojo.byId("divDlgLock"), "onkeypress", function (evt) {
        if(evt.keyCode == dojo.keys.ESCAPE) {           
            dojo.stopEvent(evt);
        }
});

Any ideas?


回答1:


By adding an output script block you can extend the existing declaration:

<xp:scriptBlock id="scriptBlockNonCloseableDialog">
   <xp:this.value>
      <![CDATA[
         dojo.provide("extlib.dijit.OneUIDialogNonCloseableDialog");
         dojo.require("extlib.dijit.Dialog");
         dojo.declare(
            "extlib.dijit.OneUIDialogNonCloseableDialog",
            extlib.dijit.Dialog,
            {
               baseClass: "",
               templateString: dojo.cache("extlib.dijit", "templates/OneUIDialog.html"),
               disableCloseButton: true,
               _onKey: function(evt){
               if(this.disableCloseButton &&
                  evt.charOrCode == dojo.keys.ESCAPE) return;
                  this.inherited(arguments);
               },
               _updateCloseButtonState: function(){
                  dojo.style(this.closeButtonNode,
                  "display",this.disableCloseButton ? "none" : "block");
               },
               postCreate: function(){
                  this.inherited(arguments);
                  this._updateCloseButtonState();
                  dojo.query('form', dojo.body())[0].appendChild(this.domNode);
               },
               _setup: function() {
                  this.inherited(arguments);
                  if (this.domNode.parentNode.nodeName.toLowerCase() == 'body')
                     dojo.query('form', dojo.body())[0].appendChild(this.domNode);               
               }        
            }
         );

         // This is used by the picker dialog to grab the correct UI
         XSP._dialog_type="extlib.dijit.OneUIDialogNonCloseableDialog";
      ]]>
   </xp:this.value>
</xp:scriptBlock>


来源:https://stackoverflow.com/questions/12920381/non-closable-dialogbox-from-extension-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!