Dojo dialog close event on X (top-right)

一世执手 提交于 2019-12-04 01:24:17
user3489215

"Developer shouldn't override or connect to this method" for "onCancel" see documentation. A better solution is:

var myDialog = new Dialog({
   id: "myDialogId1",
   onHide: function() {
      myDialog.destroy()
   }
});

Found a solution. by using dojo.connect().

myDialog.connect(myDialog, "hide", function(e){
    dijit.byId("user_submit").destroy(); 
});

Would have postet this shortly after i posted the quistion, but I didn't have enough points, so here is the answer again, just a little late :-)

IIRC, the onClose extension event gets called when you click on the X thing, so you could try putting your cleanup code there.


You could also consider sidesteping the issue entirely. Perhaps you don't need to destroy the widget and could instead reuse the same one? You could also do a widget existence test before you create it again, destroying the old version if its still alive.

Neelesh

You can override onCancel() method as stated above or you can attach event to the dijit.dialog.closeButtonNode domElement. dijit.dialog.closeButtonNode is the name of data-dojo-attach-point attribute for close button.

Exp:

dojo.on(dijit.Dialog.closeButtonNode, "click", function(evt){
      //add your logic here
});

When pressing the X on the top of the dialog the "onCancel" event is triggered.

Dispose of the element there.

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