我正在尝试将.TPL文件内容加载到JST [“app / index”]。
loadTemplates: function(views, callback) {
var deferreds = [];
$.each(views, function(index, view) {
deferreds.push($.get('tpl/' + view + '.html', function(data) {
window['JST']["app/index"] = data;
}, 'html'));
});
$.when.apply(null, deferreds).done(callback);
}
Chrome检查器显示正在加载TPL文件,但骨干网视图无法访问JST模板。
答案 0 :(得分:0)
试试这个:
loadTemplates: function(views, callback) {
var deferreds = [];
$.each(views, function(index, view) {
deferreds.push($.get('tpl/' + view + '.html', function(data) {
if (window['JST'] === void 0) {
window['JST'] = {};
}
window['JST']["app/index"] = data;
}, 'html'));
});
$.when.apply(null, deferreds).done(callback);
}