The context of “this” in Meteor template event handlers (using Handlebars for templating)

后端 未结 2 543
庸人自扰
庸人自扰 2020-12-02 10:09

A quick question on the context of the event handlers for templates in Meteor (with Handlebars).

  • In the section of Documentation on template instances (http:/
2条回答
  •  醉梦人生
    2020-12-02 10:29

    The first parameter in the function is the event. So you could use the target of the event to grab your element.

    Template.scores.events({
      'click .click-me': function (event, template) {
        console.log(event.target);
        $(event.target).text("O but I did!");
      }
    });
    

提交回复
热议问题