Mustache.js - How to hook up data?

白昼怎懂夜的黑 提交于 2019-12-11 02:23:30

问题


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?

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


回答1:


you could use nested templates as suggested here.

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




回答2:


Check out this working example of Mustache with jQuery:

http://blog.xoundboy.com/?p=535



来源:https://stackoverflow.com/questions/6977727/mustache-js-how-to-hook-up-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!