无法访问 ModalDialog 的组件
enyo.kind({
name: "TestDialog",
kind: enyo.VFlexBox,
components: [
{kind: "ApplicationEvents", onLoad: "openDialog"},
{kind: "ModalDialog", name: "errorDialog", caption: "Error!", components: [
{kind: "HFlexBox", layoutKind: "HFlexLayout", pack: "center", components: [
{content: "Oh no!", name: "errorMessage", style: "margin: 20px 0px;", className: "enyo-text-error warning-icon"}
]},
{kind: "Button", caption: "OK", onclick: "closeErrorDialog"}
]}
],
openDialog: function() {
this.$.errorMessage.setContent("This is a sample error message");
this.$.errorDialog.openAtCenter();
}});
我不知道如何设置 this.$.errorMessage 的内容。
如果我注释掉尝试设置 this.$.errorMessage 内容的行,则对话框将正确显示原始内容。 我做错了什么?
注意:alert(this.$.errorDialog)
按预期显示 enyo.ModalDialog
,但是alert(this.$.errorMessage)
显示未定义
。对于 this.$.errorMessage
的所有其他组件也是如此。
enyo.kind({
name: "TestDialog",
kind: enyo.VFlexBox,
components: [
{kind: "ApplicationEvents", onLoad: "openDialog"},
{kind: "ModalDialog", name: "errorDialog", caption: "Error!", components: [
{kind: "HFlexBox", layoutKind: "HFlexLayout", pack: "center", components: [
{content: "Oh no!", name: "errorMessage", style: "margin: 20px 0px;", className: "enyo-text-error warning-icon"}
]},
{kind: "Button", caption: "OK", onclick: "closeErrorDialog"}
]}
],
openDialog: function() {
this.$.errorMessage.setContent("This is a sample error message");
this.$.errorDialog.openAtCenter();
}});
I can't figure out how to set the content of this.$.errorMessage.
If I comment out the line that attempts to set the content of this.$.errorMessage, the dialog displays correctly with the original content.
What am I doing wrong?
Note: alert(this.$.errorDialog)
displays enyo.ModalDialog
as expected, butalert(this.$.errorMessage)
displays undefined
. This is true for all the other components of this.$.errorMessage
as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上,我编辑了我的答案:
除非您为 ModalDialog 指定 lazy: false ,否则该控件在对话框关闭时将不存在。或者您可以在 .openAtCenter() 之后执行 .setContent()
Actually, I edited my answer:
That control won't exist while the dialog is closed unless you specify lazy: false for the ModalDialog. Or you can do the .setContent() after the .openAtCenter()