Mustache.js - How do you hook up events?

僤鯓⒐⒋嵵緔 提交于 2019-12-07 14:03:15

问题


I'm considering using Mustache.js for a small project I'm working on.... The one thing that I haven't seen an answer for is - Which is the best way to go about hooking up events?

I was thing of creating a tree menu with mustache but I can't think which would be the best or cleanest way to hook up events to each node?


回答1:


Mustache is a template engine; it's concerned only with markup, not behavior. To wire in events you should use the same best practices with HTML generated by hand or with any other templating engine--that is, by attaching events to nodes using addEventListener or with your library of choice's (jQuery/Prototype/Dojo/YUI) preferred methods. Just give your nodes appropriate ids and classnames in your templates and do the rest as usual.



来源:https://stackoverflow.com/questions/4101586/mustache-js-how-do-you-hook-up-events

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