4
在我的应用程序添加Marionette.sync插件并重写这些方法:外部把手模板骨干木偶
Backbone.Marionette.TemplateCache.prototype.loadTemplate = function (templateId, callback) {
var tmpId = templateId.replace("#", ""),
url = "/app/templates/" + tmpId + ".html";
$.get(url, function (templateHtml) {
compiledTemplate = Handlebars.compile($(templateHtml).html())
callback.call(this, compiledTemplate);
});
};
Backbone.Marionette.Renderer.renderTemplate = function (template, data) {
template(data);
};
但这不能正常工作,任何想法?
感谢您的回答Derick。我使用github存储库中的文档和wiki。 – camaya
亲爱的德里克,看起来像你的代码不工作,因为“loadTemplate”函数被从backbone.marionette.templatecache中的内部“加载”函数调用:58 //加载模板并编译它 var template = this。 loadTemplate(this.templateId); this.compiledTemplate = this.compileTemplate(template); 此函数不会将回调作为第二个参数传递,并且代码失败,并显示错误“callback is undefined”。 – AndreyM
我也和安德烈有同样的问题。什么需要改变它的工作? – blessenm