Okey. so im trying to grab niceArray in hello.events. But it seems like its not global.
If i create the array (not sure if it is called array or object) outside the helpers. It becomes global and i can use it anywhere. But the problem with this is that it doesnt get updated to the client if i change something in it.
var niceArray = [ .... values ... ];
Template.hello.events({
'click .doit': function (e) {
var blabla = niceArray[(e.target.dataset.id) - 1];
I don’t think that’s valid syntax for Meteor helpers. Helpers are expected to be functions that return something to be used in a template via {{helperName}}.
If you’re going to use Session, introduce some sort of namespacing or grouping in your variable names to keep things clean. Session.set('group/specificName', ...).
Im not going to add more stuff to the array, just change a variable slightly. So i think this is enough for now. But ill think about it as i continue developing
Template.hello.events({
'click .doit': function (e) {
var stuff = Session.get('coolNamespace/pikachu')[(e.target.dataset.id)
var chance = stuff.chance;
I’m using this though to grab the chance from the object to hello.events. I dont think that solution is possible?
I’m new at meteor so im sorry if i am slow
EDIT:
I got it working! ^^
var chance = (stuff.chanceMultiplier) * Session.get(‘level’);