我很难从我的主视图实例中“绑定”我的路由器事件。我的第一个想法是因为路由器只会触发我的Depths
收藏。我将如何正确通知我viewpoint.js
有关页面更改的信息?
路由器.js
var depth = depth || {};
(function() {
'use strict';
var DepthRouter = Backbone.Router.extend({
routes: {
'*page' : 'setPage'
},
setPage: function( page ) {
// Set the current page
page = page.trim() || 'home';
// Trigger a collection {page} event
depth.Depths.trigger(page);
}
});
... // instance creation and Backbone.history.start() stuff
}());
观点.js
var depth = depth || {};
$(function($) {
'use strict';
depth.Viewpoint = Backbone.View.extend({
el: 'section#right > div.content',
// Bind relevant triggers
initialize: function() {
},
});
});