jsfiddleに例を作成しました。また、私はここにコードをドロップします:ArrayProxyのエントリを他のオブジェクトのプロパティにバインドできますか?
Javascriptを:
window.App = Ember.Application.create();
TypeA = Ember.Object.extend({
propertyA: ""
});
TypeB = Ember.Object.extend({
propertyB: ""
});
App.someController = Ember.ArrayProxy.create({
content: []
});
var aa = TypeA.create({propertyA: "aa"});
var ab = TypeA.create({propertyA: "ab"});
var ba = TypeB.create({propertyB: "ba"});
var bb = TypeB.create({propertyB: "bb"});
// I'm probably just copying the string here so sort of realizing
// that the binding "breaks", however I don't get how to maintain the "bond".
App.someController.pushObject(aa.get("propertyA"));
App.someController.pushObject(ab.get("propertyA"));
App.someController.pushObject(ba.get("propertyB"));
App.someController.pushObject(bb.get("propertyB"));
// I'd like this to update the value "aa" in the list
aa.set('propertyA', "AA");
HTML:
<script type="text/x-handlebars">
{{#collection contentBinding="App.someController" tagName="ul"}}
{{content}}
{{/collection}}
</script>
のでsomeController
のエントリのソースは、様々な異なるオブジェクトすることができますが、間の結合をオブジェクトのプロパティとsomeControllerのエントリを保持する必要があります。これを行う簡単な方法は?私はsomeController
の値をいくつかのオブジェクトまたはビューにラップすることを考えましたが、非グローバルなオブジェクトへのバインディングを作成する方法が見つかりませんでした(すべてのバインドは、完全なグローバルパスを使用していたようです(例:"App.someObject.property"
)
非常に感謝しています!ありがとう。
さらに良いバージョン:[http://jsfiddle.net/r6f3P/](http://jsfiddle.net/r6f3P/)]。 – karihre
そして、#$%が更新されないうちに変更を行うと、最後には機能しませんでした。 – karihre
修正が見つかりました.. – karihre