ReactiveVar get() not responding in Events

So when a button is pressed, my app should take a reactive var and increment it. For some reason, events will allow me to set the reactivevar, but if I try to use get within an event, it always returns the original value of the reactive var.

In the example below, no matter how many times I click .quickChange, the rating ReactiveVar will always be ‘1’. I’ve manually set it to other values, confirmed that it’s correct, then hit .quickChange and it goes back to ‘1’.

Any idea what’s happening?

    this.rating = new ReactiveVar(0);
    "click .quickChange": function(e, template) {
        template.rating.set(template.rating.get() + 1);

Works here. Is there some other code you are not showing?

I’m thinking it might be connected to how I’m creating the template, which is this:

{{#each task in taskCollection}}
    {{>slider_task task}}

I’ve realized that I have identical code in another place in my app, and it works fine. Which makes me think that there’s some issue with creating templates in this way.

That shouldn’t matter. I just created a little test and it worked.


<template name="counters">
	<div class="well">

	<div class="content">
		{{#each counter in counters}}
			{{>counter_test counter}}

<template name="counter_test">
	<div class="panel panel-default">
		<div class="panel-heading">{{name}}</div>
		<div class="panel-body">
			<button class="btn btn-success">Increment
				<span class="badge">{{counter}}</span>


import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';
import './counters.html';

		return [
			{name: "one"},
			{name: "two"},
			{name: "three"}

	this.value = new ReactiveVar(0);
		var template = Template.instance();
		return template.value.get();
	'click button'(event, template){
1 Like