質問

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, but
alert(this.$.errorMessage) displays undefined. This is true for all the other components of this.$.errorMessage as well.

役に立ちましたか?

解決

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()

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top