I’m trying to update a reactive var in my template with a value returned from a method on the server. I can see that the server is returning a value but I cant set the var myvar1 in the code below. What am I doing wrong? Thanks for any help.
Meteor.call('mymethod', arg1, function(err, ret) {
// Also tried this and self
Template.instance().myvar1.set(ret);
and if you do in that onCreated. (And BTW it is onCreated in current meteor version, not created)
self = this;
and in that callback
self.myvar1.set(ret);
? there was thread regarding similar scoping inside callbacks on these forums.
But I dont remember what was the solution, I would try this one first probably.
YES, thats the way to do it. Thanks a lot Steve and shock.
In other situations with callbacks it usually works to do self = this and then use self in callback but not this time and with reactive var. Nice and easy solution, thanks.