Skip to content

Instantly share code, notes, and snippets.

@frankapimenta
Last active December 9, 2015 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frankapimenta/08f1d371d0dec2bdc9f3 to your computer and use it in GitHub Desktop.
Save frankapimenta/08f1d371d0dec2bdc9f3 to your computer and use it in GitHub Desktop.
update of reactive var
https://github.com/jagi/meteor-astronomy-examples/blob/flowrouter/
On the repo above on the collections.js file I did the following:
...
Users = new Mongo.Collection('users');
Users.allow({
update: function() { return true; }
});
Users.deny({
update: function() { return false; }
});
...
Then on I put a console.log on line 25.
---
Template.UserForm.onCreated(function() {
var _id = FlowRouter.getParam('_id');
if (_id) {
this.subscribe('user', _id);
var user = Users.findOne(_id);
console.log(user);
this.data.user = new ReactiveVar(user);
} else {
this.data.user = ReactiveVar(new User());
}
});
---
I run the application, I create a user and I go to the edit route.
The user now can be seen on browser console (due to console.log of line 25)
I store it on global variable temp1 (with right click of mouse on the logged User class instance)
I do:
temp1.set('firstName', 'whatever');
and the input does not change the text to whatever
When I do:
temp1.save()
It does not update the input.
How can a reactive var make the template to be re-render?
thank you
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment