- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在调用 this._oDialog.destroy()
后尝试再次打开 Dialog 片段时,出现以下错误:
Uncaught TypeError: Cannot read property 'setInitialFocusId' of null
我的问题就像此处所述的问题:How to clear dialog/xmlfragment content after close?但是,解决方案显然似乎只是“不要使用属性 setInitialFocus”,我没有在我的代码中的任何地方使用它。
openDialog: function() {
if (!this._oDialog) {
this._oDialog = sap.ui.xmlfragment("myFragmentPath", this);
this.getView().addDependent(this._oDialog);
}
this._oDialog.open();
},
onExit: function () {
if (this._oDialog) {
this._oDialog.destroy();
}
},
afterClose: function () {
if (this._oDialog) {
this._oDialog.destroy();
}
},
handleClose: function (oEvent) {
this._oDialog.close();
}
<Dialog xmlns="sap.m" afterClose=".afterClose">
<!-- ... -->
</Dialog>
<Button press=".openDialog" />
附加信息:
this._oDialog.open();
时,Controller 行中出现错误消息。最佳答案
if (this._oDialog) {
this._oDialog.destroy();
this._oDialog = null; // make it falsy so that it can be created next time
}
关闭后,对话框在您的代码中被销毁。 但是, this._oDialog
还在那里。
自 this._oDialog
不是虚假值,而只是一个销毁 对话框实例,openDialog()
中没有创建新的对话框第二次。因此,您正试图打开一个被破坏的对话框。
当对话框被销毁时,它的内部 oPopup
是set to null ,其中解释了错误消息。
关闭后通常不需要销毁对话框。当 View 被销毁时,对话框将自动销毁,因为片段依赖于 View 。如果打算重置数据值,请尝试 unbinding properties而不是每次都销毁并重新创建整个片段,这是非常昂贵的。
自 UI5 1.56 起,工厂函数 sap.ui.xmlfragment
已弃用,因为它通过同步 XHR(阻塞主线程)获取片段。使用 new asynchronous APIs 之一.
一个更简单的选择是使用 <core:Fragment fragmentName="..." type="XML" />
在您的 View 定义中以声明方式添加片段到 <dependents>
某种控制的聚合。 Like in this sample .
关于javascript - _oDialog.destroy() 后出现 "setInitialFocusId"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54214764/
在调用 this._oDialog.destroy() 后尝试再次打开 Dialog 片段时,出现以下错误: Uncaught TypeError: Cannot read property 'set
我是一名优秀的程序员,十分优秀!