Mustache.js - How do you hook events?

I am considering using Mustache.js for a small project that I am working on ... The only thing I have not seen an answer to is the best way to connect to events?

I was going to create a tree-like menu with a mustache, but I can’t imagine which one would be the best or cleanest way to connect events to each node?

+3
source share
1 answer

Mustache is a pattern engine; it only concerns markup, not behavior. To connect to events, you must use the same best practices for working with HTML generated manually or using any other template engine, i.e. by attaching events to nodes using addEventListener or with your library of choice (jQuery / Prototype / Dojo / YUI) preferred methods. Just give your nodes the appropriate identifiers and class names in your templates and do everything as usual.

+7
source

Source: https://habr.com/ru/post/1773138/


All Articles