Mustache.js - 如何连接数据? [英] Mustache.js - How to hook up data?

查看:98
本文介绍了Mustache.js - 如何连接数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢生成标记,同时使用jQuerys数据方法将数据添加到标记中的节点存储任意与匹配元素相关联的数据。是否有一些方法可以使用Mustache或一些解决方法?

I like to generate markup and at the same time adding data to nodes in the markup with jQuerys data method Store arbitrary data associated with the matched elements. Is there some way to do that with Mustache or some workaround?

请参阅此jsFiddle以获取代码参考: http://jsfiddle.net/fiddlebjoern/edyYu/

See this jsFiddle for code reference: http://jsfiddle.net/fiddlebjoern/edyYu/

推荐答案

您可以按照建议使用嵌套模板此处

you could use nested templates as suggested here.

您的列表项是第二个模板。现在,每次你想要附加数据时,用你的第二个模板运行它并调用jquerys append方法。

Your list item being the second template. Now each time you want to append data run it by your second template and call jquerys append method.

这听起来不错吗?那是你想要的吗?你的问题有些不清楚

Does that sound good? Is that what you wanted? Your question was somewaht unclear

这篇关于Mustache.js - 如何连接数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆