3

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?

4

1 に答える 1

7

Mustacheはテンプレートエンジンです。動作ではなく、マークアップのみに関係します。イベントをワイヤリングするには、手動または他のテンプレートエンジンで生成されたHTMLで同じベストプラクティスを使用する必要があります。つまり、addEventListenerを使用してノードにイベントをアタッチするか、選択したライブラリ(jQuery / Prototype / Dojo / YUI)を使用します。メソッド。テンプレートでノードに適切なIDとクラス名を指定し、残りは通常どおり実行します。

于 2010-11-04T21:33:45.567 に答える