我的对话框定义为document:
onOpenDialog : function () {
var oView = this.getView();
var oDialog = oView.byId("helloDialog");
// create dialog lazily
if (!oDialog) {
// create dialog via fragment factory
oDialog = sap.ui.xmlfragment(oView.getId(), "sap.ui.demo.wt.view.HelloDialog");
oView.addDependent(oDialog);
}
oDialog.open();
}
假设这个对话框有很多Input/Select/ComboBox等,用户在其中输入,关闭,导航到另一个主项和详细信息页面,再次打开这个对话框实例,信息仍然在这里。如果我想在用户每次关闭它时清除信息/输入怎么办?
关闭后销毁此对话框是解决此问题的唯一方法吗?
对话框 XML
<Dialog afterClose="dialogAfterclose" >
<beginButton>
<Button text="yes" press="confirmOk"/>
</beginButton>
<endButton>
<Button text="no" press="confirmCancel"/>
</endButton>
</Dialog>
创建对话框
if(!this._oDialog){
this._oDialog = sap.ui.xmlfragment("idFragment","Path_to_your_Dialog", this);
}
你需要使用destroy()
of the sap.ui.core.Element
.
dialogAfterclose: function(oEvent) {
this._oDialog.destroy();
}
根据你的代码
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()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)