【发布时间】:2015-10-11 23:08:16
【问题描述】:
我一直在尝试实现外部模板,但无济于事。 这是完整的错误:
Uncaught TypeError: Invalid template! Template should be a "string" but "undefined" was given as the first argument for mustache#render(template, view, partials)
我将browserify-shim 用于其他一些依赖项,但它们运行良好,并且我没有从终端收到错误(来自该任务)。只是外部模板加载给我带来了问题。
function templateLoader(e) {
var doc = document,
event = EventUtility.getEvent(e),
target = EventUtility.getTarget(event);
$("body").load("templates/index.html #overlay", function() {
var temp1 = $('#overlay').html();
var output = Mustache.render(temp1);
$("body").html(output);
});
}
var flimFlam = document.getElementById('Container');
EventUtility.addHandler(flimFlam, 'click', templateLoader);
提前非常感谢!
【问题讨论】:
标签: javascript jquery templates mustache