Closed loatherer closed 8 months ago
Hello @loatherer,
this seems to be an issue with the oDialog references.
Please adjusted your code as follows so that it works with the correct references:
sap.ui.define(
["sap/ui/core/mvc/Controller", "sap/ui/core/Fragment"],
function (Controller, Fragment) {
"use strict";
return Controller.extend("sap.ui.demo.walkthrough.view.App", {
getDialog: async function () {
if (!this.oDialog) {
this.oDialog = await Fragment.load({
id: this.getView().getId(),
name: "sap.ui.demo.walkthrough.view.Dialog",
controller: this,
});
this.getView().addDependent(this.oDialog);
}
return this.oDialog;
},
onOpenDialog: function () {
this.getDialog().then((oDialog) => {
oDialog.open();
});
},
closeDialog: function () {
this.getDialog().then((oDialog) => {
oDialog.close();
});
},
});
}
);
If you for some reason need to destroy the dialog before you close it the code should look like so:
getDialog: async function () {
if (!this.oDialog) {
this.oDialog = await Fragment.load({
id: this.getView().getId(),
name: "sap.ui.demo.walkthrough.view.Dialog",
controller: this,
});
this.getView().addDependent(this.oDialog);
}
return this.oDialog;
},
onOpenDialog: function () {
this.getDialog().then((oDialog) => {
oDialog.open();
});
},
closeDialog: function () {
this.getDialog().then((oDialog) => {
oDialog.close();
oDialog.destroyContent();
oDialog.destroy();
this.oDialog = null;
});
},
Let me know if you face any issues with the refactored code.
Kind Regards, Dobrin
Hello @dobrinyonkov , Thanks for your fast response, i created a new plunkr according to your code however my problem still occurs when i destroy the dialog and try to open it. Plnkr: https://plnkr.co/edit/Ne4WB6EXLXq5gIMu?preview
Plnkr:
On my machine :
Regards, Mete
OpenUI5 version: 1.108.14
Browser/version (+device/version): Google Chrome/ Version 120.0.6099.110
Any other tested browsers/devices(OK/FAIL):
URL (minimal example if possible): https://plnkr.co/edit/lWD7gBZFod2HQRcf?preview
Steps to reproduce the problem:
What is the expected result? The dialog should open. What happens instead? Dialog doesn't open. Any other information? (attach screenshot if possible)