Disable the close button for a dojo / dijit.Dialog

  1. dojo.provide("myWidgets.Dialog");
  2.  
  3. dojo.declare
  4. (
  5. "myWidgets.Dialog",
  6. [dijit.Dialog],
  7. {
  8. // summary:
  9. // extended version of the dojo Dialog widget with the option to disable
  10. // the close button and supress the escape key.
  11.  
  12. disableCloseButton: true,
  13.  
  14. /* *********************************************************** postCreate */
  15. postCreate: function()
  16. {
  17. this.inherited(arguments);
  18. this._updateCloseButtonState();
  19. },
  20.  
  21. /* *************************************************************** _onKey */
  22. _onKey: function(evt)
  23. {
  24. if(this.disableCloseButton && evt.charOrCode == dojo.keys.ESCAPE) return;
  25. this.inherited(arguments);
  26. },
  27.  
  28. /* ************************************************ setCloseButtonDisabled*/
  29. setCloseButtonDisabled: function(flag)
  30. {
  31. this.disableCloseButton = flag;
  32. this._updateCloseButtonState();
  33. },
  34.  
  35. /* ********************************************** _updateCloseButtonState */
  36. _updateCloseButtonState: function()
  37. {
  38. dojo.style(this.closeButtonNode,
  39. "display",this.disableCloseButton ? "none" : "block");
  40. }
  41. }
  42. );

Comments

Just what i needed

Thanks this is exactly what i needed!