我在ICanHaz.js文档中读到,我应该像这样从远程加载模板
$.getJSON('/myserver/templates.json', function (templates) {
$.each(templates, function (template) {
ich.addTemplate(template.name, template.template);
});
});我不知道json模板应该是什么样子,我真的很喜欢一个示例ICanHaz.js json模板。
谢谢
发布于 2012-01-24 07:27:05
为了节省调试$.each的时间,回调函数需要两个参数:迭代器和实际对象
$.getJSON('/myserver/templates.json', function (templates) {
$.each(templates, function (id, template) {
ich.addTemplate(template.name, template.template);
});
});当然,您必须记住设置promise,因为这些模板是在异步模式下加载的。
https://stackoverflow.com/questions/8682434
复制相似问题