1

実行時に作成されるボタンを表示するアプリが必要です。その理由は、サービスから情報を取得して、必要なボタンの数を確認するためです。

現在、プログラムは実行されていますが、ボタンは表示されません。

ツールバーを使用して、create 関数でコントロール プロパティを設定しようとしています。プログラムは正常に実行されますが、ツールバーにボタンがありません。これを行う方法はありますか?

コード:

// Trying to create buttons at run time
name: "MyApps.MainApp",
kind: enyo.VFlexBox,
components: [
        {kind: "PageHeader", content: "Template"},
        {kind: "Toolbar", name: "tabsted"},
        {name: "feedUrl", kind: "Input", flex: 1},
        {kind: "HtmlContent", name: "comments", content: "hello world <br> and another lin"},
        {name:"curValue", content:("Sample Text \r\n and more")},
        {kind: "Button", caption: "Action", onclick: "btnClick"},
],

// this gets called first ha
create: function()
{
    this.inherited(arguments);

    this.$.tabsted.components= [
            {caption: "a"},
            {caption: "b"},
            {caption: "c"}
    ];

    this.LoadCommments();
    },

    LoadCommments: function()
    {
        this.$.comments.content="fred";   
    },

    // called when button is clicked
    btnClick: function() 
    {
        this.$.curValue.setContent("Put some text here");  // handle the button click
    }
};
4

1 に答える 1

2

Enyo.ComponentのAPIドキュメントを確認することをお勧めします。具体的には、コンポーネントを動的に作成するセクションです。コードに次の変更を加えてみてください。

    this.$.tabsted.createComponents([
        {caption: "a"},
        {caption: "b"},
        {caption: "c"}
    ], {owner: this});

また、LoadComments関数では、コンテンツの値を直接更新するのではなく、「setContents」を呼び出す必要があります。

于 2012-01-02T05:41:51.583 に答える