my Problem is that I am currently trying to access a ReactiveDict in an EventListener inside the same Template. The creation in my onCreated seems to work. But when I am trying to access it it is always undefined. Can anybody please have a look?
Event Listener:
Template.bierwart_getrankezahlen.events({
'click .minus1'(event, instance) {
const id = this._id;
const current = instance.zahlen.get(id);
instance.zahlen.set(id, current - 1);
},
getrankezahlen.js:26 Uncaught TypeError: Cannot read property 'get' of undefined
at Object.click .minus1 (getrankezahlen.js:26)
at blaze.js?hash=cbd85c3fe14949f2d2b9a3b76334f5f0e96d553c:3818
at Function.Template._withTemplateInstanceFunc (blaze.js?hash=cbd85c3fe14949f2d2b9a3b76334f5f0e96d553c:3769)
at Blaze.View.<anonymous> (blaze.js?hash=cbd85c3fe14949f2d2b9a3b76334f5f0e96d553c:3817)
at blaze.js?hash=cbd85c3fe14949f2d2b9a3b76334f5f0e96d553c:2617
at Object.Blaze._withCurrentView (blaze.js?hash=cbd85c3fe14949f2d2b9a3b76334f5f0e96d553c:2271)
at Blaze._DOMRange.<anonymous> (blaze.js?hash=cbd85c3fe14949f2d2b9a3b76334f5f0e96d553c:2616)
at HTMLButtonElement.<anonymous> (blaze.js?hash=cbd85c3fe14949f2d2b9a3b76334f5f0e96d553c:863)
at HTMLElement.dispatch (modules.js?hash=0a505f8664c68b3ed522d3b90b1ce95e4ec8bc87:39917)
at HTMLElement.elemData.handle (modules.js?hash=0a505f8664c68b3ed522d3b90b1ce95e4ec8bc87:39725)
Okay - I’ve just seen the problem. You can’t use fat arrows in onCreated or onRendered, so Template.bierwart_getrankezahlen.onCreated(() => { needs to be Template.bierwart_getrankezahlen.onCreated(function() {