我有这个骨干视图,当这个页面被渲染时,来自子页面的小内容也将呈现给父页面。
父页
define([
'jquery',
'underscore',
'backbone',
'text!../../../../school-admin/studentHealthRecord.html',
'views/schoolModule/viewStudentHealthView'
], function (
$,
_,
Backbone,
healthRecordTemplate,
ViewStudentHealthView
) {
var StudentHealthRecordView = Backbone.View.extend({
// target item.
el : $("#schoolContentOuterPnl"),
render : function() {
var data = {};
// template
var healthcompiledTemplate = _.template(healthRecordTemplate, data);
// append the item to the view's target
this.$el.html(healthcompiledTemplate);
this.viewHealthClickEvent();
},
// Event Handlers
events : {
},
viewHealthClickEvent : function(){
new ViewStudentHealthView({
el : $("#divSchoolHealthViewEdit")
});
},
});
return new StudentHealthRecordView;
});
子页面
define([
'jquery',
'underscore',
'backbone',
'text!../../../../school-admin/viewHealthRecord.html'
], function(
$,
_,
Backbone,
ViewStudentHealthTemplate
) {
var ViewStudentHealthView = Backbone.View.extend({
initialize: function(){
this.render();
},
render : function() {
// template
var data = {};
var ViewStudentHealthCompiledTemplate = _.template(ViewStudentHealthTemplate, data);
// append the item to the view's target
this.$el.html(ViewStudentHealthCompiledTemplate);
},
// Event Handlers
events : {
}
});
return new ViewStudentHealthView;
});
初始化父页面时,也应初始化子项,但显示$不是函数。