Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
429 views
in Technique[技术] by (71.8m points)

javascript - 我如何甚至在mustache.js模板中也可以捕获按钮单击(How can I capture button click even inside mustache.js template)

I have a mustache template as follows

(我有一个小胡子模板,如下)

<script id="template" type="x-tmpl-mustache">
 <div class="row">
                 {{#sums}}
                 <button {{sum}} type ="button" class="btn-primary">{{value}}
                 {{/sums}}
              </div>
</script>

I want to capture the click events on each button of the template , this how I rendered the template:

(我想捕获模板每个按钮上的click事件,这就是我渲染模板的方式:)

 Mustache.parse(template);
    let tempData = [];
   tempData.push({
                    sum,value
                });
                let  rendered = Mustache.render(template, tempdata);
                $('#block').append(rendered);
  ask by Sabrina translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...