2012-02-15 7 views
2

私の選択したタグコントローラの内容に従って、ドキュメントコントローラの内容をフィルタリングしようとしています。私はこれが最善の解決策であるかどうか分からないので、代替案を自由に提案してください。「このプロパティにアクセスするにはEmber.set()を設定する必要があります」という結果が表示されるのはなぜですか?

この不確実性を除いて、誰でも次の結果がassertion failed: Must use Ember.set() to access this propertyにある理由を説明できますか?特にselectedTagsBinding: "App.selectedTagsController.content"が失敗します。

App = Ember.Application.create(); 

App.documentsController = Ember.ArrayProxy.create({ 
    content: [], 

    selectedTagsBinding: "App.selectedTagsController.content" 
}); 

App.selectedTagsController = Ember.ArrayProxy.create({ 
    content: [ new Ember.Object(), new Ember.Object() ] 
}); 

答えて

2

UPDATEは:ud3323が彼の答えで述べたように、これはバグではなく、この答えは、これは明らかにバインディングのバグである前App.set


の私の知識に書き込まれています。 App.selectedTagsControllerの宣言をApp.documentsControllerの前に移動します。

App = Ember.Application.create(); 

App.selectedTagsController = Ember.ArrayProxy.create({ 
    content: [ new Ember.Object(), new Ember.Object() ] 
}); 

App.documentsController = Ember.ArrayProxy.create({ 
    content: [], 

    selectedTagsBinding: "App.selectedTagsController.content" 
}); 
4

実際これはバグではありません。あなたはこのようなあなたのコントローラを設定する必要があります:http://ud3323.github.com/2012/02/15/ember-controllers-and-the-runloop.html

App.set('documentsController', Ember.ArrayProxy.create({ 
    selectedTagsBinding: "App.selectedTagsController" 
})); 

App.set('selectedTagsController', Ember.ArrayProxy.create({ 
    content: [ 
     Ember.Object.create({ 
      name: "john" 
     }), Ember.Object.create({ 
      name: "sal" 
     }) 
    ] 
})); 

は、私はここでは詳細にあなたのエラーを説明する短いブログ記事を書きました。

+0

ご清聴ありがとうございます! – pangratz

+0

問題ありません。私は実際に私自身のコードで同じことをすることから時々自分自身をキャッチする必要があります:) –