问题描述
我有两个模板(标题和详细信息) - 标题包含一些细节,也包含详细信息部分的占位符 - 详细信息包含更多详细信息。
我的问题是当我运行应用程序时它不会取代标题占位符中的详细信息模板。
查看1
I have two templates (Header and Details) - Header contains some details and also on place holder for Details sections - Details contain some more details.
My problem is when i run application it will not replace Details template inside the placeholder of the Header.
View 1
var CalendarView = Backbone.View.extend({
el: '#header',
model: todo,
initialize: function () {
this.render();
this.monthView = new MonthView({ el: "#dvDetail", model: this.model });
},
render: function () {
template.render("testHeader.htm", $(this.el), { data: this.model.toJSON() });
}
});
查看2
View 2
var MonthView = Backbone.View.extend({
initialize: function () {
this.model.bind("change", this.render, this);
this.render();
},
render: function () {
template.render("testDetail.htm", $(this.el), { data: this.model.toJSON() });
}
});
index.html
index.html
<div id="header"></div>
testHeader.htm
testHeader.htm
<div>This is header </div>
<div id="dvDetail">Sub template should be replace here...</div>
testDetail.htm
testDetail.htm
<div>This is details template and replaced on #dvDetail html</div>
当我运行它将显示的应用程序
这是标题
子模板应该在这里替换...
我需要
这是标题
这是详细信息模板并替换为#dvDetail html
任何机构都可以让我知道此代码中缺少什么来获得所需的输出吗?任何线索都将受到高度赞赏!
When i run the application it will display
This is header
Sub template should be replace here...
I would require
This is header
This is details template and replaced on #dvDetail html
Can any body let me know what was missing in this code to get desired output? Any clue would be highly appreciated!
推荐答案
查看2
View 2
var MonthView = Backbone.View.extend({
initialize: function () {
this.model.bind("change", this.render, this);
this.render();
},
render: function () {
template.render("testDetail.htm",
index.html
index.html
<div id="header"></div>
testHeader.htm
testHeader.htm
<div>This is header </div>
<div id="dvDetail">Sub template should be replace here...</div>
testDetail.htm
testDetail.htm
<div>This is details template and replaced on #dvDetail html</div>
当我运行应用程序时它将显示
这是标题
子模板应该被替换在这里...
我需要
这是标题
这个是详细信息模板并替换为#dvDetail html
任何机构都可以让我知道此代码中缺少什么来获得所需的输出?任何线索都将受到高度赞赏!
When i run the application it will display
This is header
Sub template should be replace here...
I would require
This is header
This is details template and replaced on #dvDetail html
Can any body let me know what was missing in this code to get desired output? Any clue would be highly appreciated!
这篇关于子模板不使用主干和下划线进行渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!