1

私は次のものを持っています:

テンプレート

    {{#each item in controller.pagedAutomationExceptions}}
    {{log item}}

    <tr {{bindAttr class="item.rowClass"}}>
        <td class="text-center">{{unbound item.BTicket}}</td>
        <td>{{unbound item.Reason}}</td>
        <td>{{unbound item.TimeReceived}}</td>
        <td>
            {{#if item.ShowContactVoltageSources}}
                {{view Ember.Select 
                    contentBinding="controller.contactVoltageSources" 
                    optionValuePath="content.Name" 
                    optionLabelPath="content.Name" 
                    valueBinding="item.AutomationValue" 
                    prompt="Choose one..."}}
            {{/if}}
            
            {{#if item.ShowVoltageField}}
                {{view Ember.TextField valueBinding="item.AutomationValue"}}
            {{/if}}

            {{#if item.ShowEnergizedObjects}}
                {{view Ember.Select 
                    contentBinding="controller.energizedObjects" 
                    optionValuePath="content.Name" 
                    optionLabelPath="content.Name" 
                    valueBinding="item.AutomationValue" 
                    prompt="Choose one..."}}
            {{/if}}
        </td>
        <td>
            {{#if item.Errored}}

            {{/if}}
               
            {{#if item.IsUpdating}}
            <btn class="btn btn-primary" disabled="disabled">
                Updating..
            </btn>
            {{else}}
            <btn {{action updateAutomationException item target="controller"}} 
                class="btn btn-primary">
                Update
            </btn>
            {{/if}}
        </td>
    </tr>
    {{/each}}

コントローラ

(正確でない場合は申し訳ありませんが、私は記憶からそれを行っており、問題を解決しようとして変更しました)

App.Exception = Ember.Object.extend({
    // properties used in template, etc..
});

App.ExceptionsController = Ember.Controller.extend({
    init: function () {
        this._super();

        // ajax request to get exceptions from database
        // once inspections are loaded
        // set(automationExceptions, response)
        // loadMoreExceptions()
    },

    automationExceptions: [],

    pagedAutomationExceptions: Ember.A(),

    loadMoreExceptions: function () {

        // i have a variable that i store to tell me 
        // how many exceptions I'm currently showing.
        // If there are more, I just add to this variable
        // the paging amount, and for those elements 
        // create a new exception and add it to the 
        // paged array. This method also seems to work
        // because I get more records on the view.
        for (; currentTake < newTake; ++currentTake) {
            var simple = automationExceptions[currentTake];
            this.get('pagedAutomationExceptions').pushObject(
                App.Exception.create(simple));
        }

    },

    updateAutomationException: function () {

        // ajax post update, this works fine..

    }
});

ルートを変更しようとすると、次のエラーが発生します。

キャッチされていない TypeError: 未定義のプロパティ 'IsUpdating' を読み取ることができません

その行を削除すると、読み取れない他のプロパティがあります。

何が起こっているのかわかりません。明らかに、Ember はどういうわけか未定義のオブジェクトを取得していますが、その方法がわかりません。すべてのオブジェクトをインスタンス化し、それらを配列にプッシュします。

4

0 に答える 0