html – 从远程服务器中提取icanhaz模板

html – 从远程服务器中提取icanhaz模板,第1张

概述icanhaz文档以此为例说明如何从远程服务器中提取ich模板. $.getJSON('/myserver/templates.json', function (templates) { $.each(templates, function (template) { ich.addTemplate(template.name, template.template); icanhaz文档以此为例说明如何从远程服务器中提取ich模板.
$.getJsON('/myserver/templates.Json',function (templates) {    $.each(templates,function (template) {         ich.addTemplate(template.name,template.template);    });});

但是,文档并没有真正告诉您远程服务器上的文件必须是什么样子.有人有主意吗?

解决方法 您的模板JsON对象可能如下所示:
{   "templates": {"name": "optionTemplate","template": "{{#options}}<option value='{{value}}'>{{display}}</option>{{/options}}"                }}

这将为选择框中的选项定义模板.

您可以使用您指定的代码添加模板(实际上我稍微调整了一下,因为我无法按照指定的方式工作):

$.getJsON('templates.Json',function () {        ich.addTemplate(this.name,this.template);    });});//Now call getJsON on your input data$.getJsON('options.Json',function (data) {    var optionElements = ich.optionTemplate(data);    $('#selectBox').append(optionElements);}

为清楚起见,这里是options.Json包含的内容:

{  "options": [             { "value": "optionValue","display": "optiondisplay"             },{ "value": "optionValue2","display": "optiondisplay2"             }]}

请告诉我你是如何得到的:)

总结

以上是内存溢出为你收集整理的html – 从远程服务器中提取icanhaz模板全部内容,希望文章能够帮你解决html – 从远程服务器中提取icanhaz模板所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1126932.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存