Getting a problem with meteor 1.2 and reactivevar


#1

I am trying to do something like as follows with an html component.

Template['ActionButton'].events({
  'click button[data-action="activate"]': function (e, template) {
    template.executing.set(true);
    Meteor.apply(template.data.method, template.data.args.split(','), {
      wait: false
    }, () => template.executing.set(false));
  }
});
Template['ActionButton'].onCreated(function () {
  this.executing = new ReactiveVar(false);
});

Then in my jade template.

template("ActionButton")
  button(data-action="activate" disabled="get executing")
    | {{ text }}

However, it seems that it is never setting this reactive var or making it update on the template.

What’s the deal? Did something change in 1.2?


#2

In your event handler, you get access to the onCreated this using the template parameter from the function definition, so:

Template['ActionButton'].events({
  'click button[data-action="activate"]': function (e, template) {
    template.executing.set(true);
    Meteor.apply(template.data.method, template.data.args.split(','), {
      wait: false
    }, () => template.executing.set(false));
  }
});