2012-11-08 22 views
1

我有一個具有綁定到模板的集合屬性的餘燼對象。當我嘗試設置該屬性是這樣的:EmberJS:設置綁定到IE中的視圖的集合屬性時出錯

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

我得到這個例外,在IE中只,其他所有瀏覽器很好地工作:

SCRIPT5022:斷言失敗:一個Ember.CollectionView的內容必須實現灰燼.Array。您通過[對象對象],[目標對象],[目標對象]

它綁定到模板是這樣的:

{{#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錯誤?

+0

如果你能提供更多的代碼/細節,會更好。 [JSFiddle](http://jsfiddle.net/)將是黃金。 – MilkyWayJoe

回答

0

我找到了解決這一問題,並張貼在這裏它:https://github.com/emberjs/ember.js/issues/1525

我使用SignalR推更新到我的餘燼的應用程序,我的代碼做這個樣子:

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

的updatedProcessingJob JSON對象包含一個數組logMessages,在IE中我得到一個錯誤,因爲這個數組沒有元哈希。要解決這個問題,我做了updatedProcessingJob的深層副本:

updatedProcessingJob = $.extend(true, {}, updatedProcessingJob) 
相關問題