1

我有一个带有绑定到模板的集合属性的 ember 对象。当我尝试像这样设置此属性时:

processingJob.set("logMessages", updatedProcessingJob.logMessages)

我只在 IE 中得到这个异常,所有其他浏览器都可以正常工作:

SCRIPT5022:断言失败:Ember.CollectionView 的内容必须实现 Ember.Array。你通过了 [object Object],[object Object],[object Object]

它像这样绑定到模板:

{{#each content.logMessages}}
    {{#isWorkflowError}}
        <li class="error"><i class="icon-thumbs-down"></i> {{message}}</li>
    {{else}}
        <li><i class="icon-thumbs-up"></i> {{message}}</li>
    {{/isWorkflowError}}
{{/each}}

当我删除模板时,我没有收到错误。我应该使用 Ember.CollectionView 还是什么?或者这是一个 IE 错误?

4

1 回答 1

0

I found a resolution to this problem and posted it here: https://github.com/emberjs/ember.js/issues/1525

I'm using SignalR to push updates to my ember app, my code to do this looks like:

App.ProcessingJobArray = Ember.ArrayProxy.extend
    init: ->
        @set("content", Ember.A())
        if $.connection
            @client = $.connection.processingJobHub
            @client.processingJobUpdated = (updatedProcessingJob) =>                
                processingJob = @get("content").find((item) ->
                    item.get("id") == updatedProcessingJob.id
                )
                if not processingJob
                    processingJob = App.ProcessingJob.create()
                    @get("content").pushObject(processingJob)
                processingJob.setProperties(updatedProcessingJob)
            $.connection.hub.start()

The updatedProcessingJob JSON object contains an array logMessages and in IE I was getting an error because there's no meta hash for this array. To fix the issue I did a deep copy of updatedProcessingJob:

updatedProcessingJob = $.extend(true, {}, updatedProcessingJob)
于 2012-11-10T13:51:18.410 回答