jsfiddle에 예를 만들었습니다.ArrayProxy의 항목을 다른 객체의 속성에 바인딩 할 수 있습니까?
자바 스크립트 : 나는 또한 여기에 코드를 내려 줄게
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"
)
많은 아이디어가 감사합니다! 감사. jsfiddle :
더 나은 또 다른 버전 : [http://jsfiddle.net/r6f3P/](http://jsfiddle.net/r6f3P/). – karihre
그리고 # $ %를 업데이트하지 않은 후에 변경 작업을 수행하면 결국 작동하지 않습니다. – karihre
수정본이 발견되었습니다. – karihre