My dialog is defined as document:
onOpenDialog : function () {
var oView = this.getView();
var oDialog = oView.byId(\"helloDialog\");
// create
Dialog XML
Create the Dialog
if(!this._oDialog){
this._oDialog = sap.ui.xmlfragment("idFragment","Path_to_your_Dialog", this);
}
You need to use destroy()
of the sap.ui.core.Element
.
dialogAfterclose: function(oEvent) {
this._oDialog.destroy();
}
As per your code
onOpenDialog : function () {
var oView = this.getView();
if (!this._oDialog) {
this._oDialog = sap.ui.xmlfragment(oView.getId(), "sap.ui.demo.wt.view.HelloDialog");
oView.addDependent(this._oDialog);
}
this._oDialog.open();
},
dialogAfterclose: function(oEvent) {//function called after Dialog is closed
this._oDialog.destroy();//destroy only the content inside the Dialog
},
confirmOk: function(oEvent) {
this._oDialog.close();//Just close the Dialog, Dialog afterClose() will be called and destroy the Dialog content.
}
Ref: sap.ui.core.Element - destroy()