// Filename: router.js
define(['jquery','underscore','backbone',
'collections/series','views/series/list','text!templates/series/list.html',
'models/series',
'views/series/details','text!templates/series/details.html',
'views/series/preview','text!templates/series/preview.html'
], function($, _, Backbone,
SeriesCollection, SeriesListView, SeriesListTemplate,
SeriesModel,
SeriesDetailsView, SeriesDetailsTemplate,
SeriesPreviewView, SeriesPreviewTemplate
){
_.templateSettings = { interpolate : /\{\{(.+?)\}\}/g };
...
更新:
所有这一切的原因是在我的路由器功能中我正在这样做:
seriesList: function(){
// We have no matching route, lets display the home page
var seriesCollection = new SeriesCollection();
seriesCollection.fetch({success:function(){
var seriesListView = new SeriesListView({collection:seriesCollection, el:'#page'});
seriesListView.template = _.template(SeriesListTemplate);
seriesListView.render();
}});
}
含义 - 我正在连接模板并在数据返回时查看。它有效 - 但这是一种好的做法吗?