【发布时间】:2011-10-10 03:12:12
【问题描述】:
我有这样的视图结构:
window.templateLoaderView = Backbone.View.extend({});
window.PopupView = templateLoaderView.extend({
initialize: function () {
this.PopupModel = new PopupModel();
this.event_aggregator.bind("tasks_popup:show", this.loadTaskPopup);
},
render: function() {
template= _.template($('#'+this.PopupModel.templateName).html());
$(this.el).html(template(this.PopupModel.toJSON()));
$('#'+this.PopupModel.containerID).html(this.el);
},
loadTaskPopup: function() {
this.PopupModel.loadTemplate("popupTask_templateHolder", "/js/templates/popup_task.html", "1", "container_dialog");
this.render();
}
});
window.TaskbarView = templateLoaderView.extend({
initialize: function () {
this.TaskbarModel = new TaskbarModel();
this.PopupModel = new PopupModel();
},
loadTaskbarPopup: function() {
this.event_aggregator.trigger("tasks_popup:show");
}
});
所以我想在一个视图中从另一个视图中运行函数。据我了解,我需要以某种方式绑定它们。是否可以在初始化函数中绑定它们?
我在这里看到了例子:Backbone.js - Binding from one view to another?。他们创建了两个对象,而不是以某种方式绑定它们。
提前致谢,
【问题讨论】:
标签: backbone.js