我正在使用Backbone Boilerplate构建一个应用程序,并且在获取下划线模板变量时遇到了一些麻烦。我有一个名为Goal的资源。我的目标视图的渲染功能如下:使用下划线变量和主干Boilerplate fetchTemplate函数
render: function(done) {
var view = this;
namespace.fetchTemplate(this.template, function(tmpl) {
view.el.innerHTML = tmpl();
done(view.el);
});
}
我打电话是另一种观点的内部,像这样:
var Goal = namespace.module("goal");
App.View = Backbone.View.extend({
addGoal: function(done) {
var view = new Goal.Views.GoalList({model: Goal.Model});
view.render(function(el) {
$('#goal-list').append(el);
});
}
});
我使用本地存储来保存我的数据,它的存在添加得很好。我可以看到它在浏览器中,但由于某些原因,当我加载应用程序,并尝试获取现有的数据,我得到这个错误:
ReferenceError: Can't find variable: title
在哪里标题为我存储的唯一关键。这是直接呼叫的结果:
tmpl();
任何想法都非常感激。
你的代码中必须有一个变量'title'。是否没有与错误消息关联的行号? – Thilo 2012-02-14 03:57:10