나는 바보 같은 짓을하고 있지만 내 백본 마리오 넷 응용 프로그램은 나에게 의미가없는 템플릿 오류를 제공하고 있음을 알고 있습니다. 가져 오기 이벤트가 발생하기 전에 단일 항목을 렌더링하는 것으로 보입니다. 내 태그 템플릿에서 콧수염을 제거하면 백본 마리오네트 가져 오기가 완료되기 전에 표시
_.templateSettings = {
interpolate: /\{\{(.+?)\}\}/g
};
MyApp = new Backbone.Marionette.Application();
MyApp.addRegions({
TagsRegion: "#tagsHolder"
});
MyApp.NoItemsView = Backbone.Marionette.ItemView.extend({
template: "#show-no-items-message-template"
});
MyApp.Tag = Backbone.Model.extend({
});
MyApp.TagCollection = Backbone.Collection.extend({
model: MyApp.Tag,
url: '/API/Tag'
});
MyApp.TagItemView = Backbone.Marionette.ItemView.extend({
template: "#tag-template",
tagName: 'li'
});
MyApp.TagCollectionView = Backbone.Marionette.CollectionView.extend({
itemView: MyApp.TagItemView,
emptyView: MyApp.NoItemsView,
tagName: 'ul'
});
MyApp.addInitializer(function(options){
var tagCollection = new MyApp.TagCollection({
});
var tagCollectionView = new MyApp.TagCollectionView({
collection: tagCollection
});
tagCollection.fetch();
MyApp.TagsRegion.show(tagCollectionView);
});
내 HTML 페이지는 1 표시
<div id="TagsDiv">
<h1>Tags</h1>
<div id="tagsHolder"></div>
</div>
<script type="text/template" id="show-no-items-message-template">
No items found.
</script>
<script type="text/template" id="tag-template">
{{ TagName }}
</script>
<script type="text/javascript" src="/Scripts/Views/Home/Upload.js"></script>
<script type="text/javascript">
$(document).ready(function() {
MyApp.start();
});
입니다 : "태그 이름"그것이 바로 수를 보여줍니다 완료된 후 때 가져옵니다. 내가 얻을에 다시 콧수염을 넣으면
나는 내가 뒤로 내 패턴 중 하나가 느낌 "태그 이름이 정의되지 않았습니다." 나는 그것을보기에는 너무 가깝다.
감사 마가 복음
id를 가진 모델을 만들고 싶다면 어떻게 해결할 수 있을까? –
질문을 이해할 수 없습니다 –
여기에 별도의 질문을 만들었습니다 : http://stackoverflow.com/questions/13567305/how-to-prevent-backbone-marionette-from-rendering-a-view-if- 그 모델은 없다. –