EmberApp에 동적 세그먼트가 리소스로로드되었습니다. 동적 세그먼트에 해당하는 컨트롤러는 ArrayController입니다. 대부분의 사람들이 알 수 있듯이 템플릿 레이어의 컨트롤러 내용이나 모델을 반복하면 각 내용이 그대로 렌더링됩니다. 그리고 내 경우에는, 'CollectionView'를 사용해야하는데, 이는 차례로 하위 뷰 모음을 정의합니다. 그 이유는 사용자 작업에 따라 이러한보기를 추가/제거해야하기 때문입니다. 그래서 짧은 이야기는 내 코드는 다음과 같습니다동적 세그먼트에서 EmberJS 컬렉션보기를 사용하면보기가 캐시됩니다.
<script type="text/x-handlebars" data-template-name="dynamicSegment">
{{view App.CollectionView}}
</script>
App.CollectionView = Ember.CollectionView.extend({
tagName: "ul" // does not have a template corresponding to it, but is generated automagically ?
itemViewClass: Ember.ChildView.extend(),
didInsertElement:function(){
this.set('content', this.get('controller').get('content')); // notice that I am setting up the content for this view in the didInsertElement method, this could be wrong, but I know no other way
},
});
App.ChildView = Ember.View.extend({
templateName:"_childView" // has a template defined within handlebars
});
<script type="text/javascript" data-template-name="_childView">
<div>{{view.content.modelProperty1}}</div> <!-- notice how I have to actually use view.content.modelProperty1 instead of simply modelProperty1
</script>
가 위, EmberJS의 배열 정보를 렌더링하는 데 약간 틀에 얽매이지 않는 방법은 당신이 말할 수있는 경우 일반적으로 하나는 단순히 것 :
{{#each}}
{{view App.ChildView}}
{{/each}}
및 그 ChildView 내
<div>{{modelProperty1}}</div>
는
수집 뷰를 사용에 대한 문제는 승, 엠버는 기본적으로 이러한 뷰,을 캐싱 것 같다 나/1에서/2와 같은 새로운 동적 세그먼트로 전환하면/2는/1 동적 세그먼트에 처음 표시된 동일한 콘텐츠를 계속 렌더링합니다.
내가 무엇을하고 있어야하며 무엇을하지 않아야합니까?
아니 도움이 있다면이 정답 또는 그것에게 일을주고, 나는이 알아 냈 내가했던 일은,이 contentBinding했다 : 내 collectionView에서 "컨트롤러"를 그런 식으로 매번 동적 세그먼트가 입력되면 내용의 기본 내용이 업데이트됩니다. 이 같은 것들이 엠버에게 자동으로 알려 지겠지만 분명히는 아니라고 생각할 것입니다. –