Hi all,
I’m trying to set up an event handler in a package function which looks like:
MyPackage = {
LocalHistory: function (templateId, formId, form) {
if (Meteor.isClient) {
var gHistory = new Mongo.Collection(null);
this.formId = formId;
this.templateId = templateId;
this.form = form;
this.isDirty = false;
var schema = AutoForm.getFormSchema(this.formId, this.form);
gHistory.attachSchema(schema);
var self = this;
console.log(this.templateId);
ReactiveTemplates.events(this.formId, {
'change form': function () {
console.log('form changed');
self.markDirty();
}
});
..........
But the ‘change form’ event handler is never called. I’ve added reactive-template and autoform to the package.js file, but doesn’t help.
api.use('aldeed:autoform');
api.use('nicolaslopezj:reactive-templates');
if I move the handler set up code to some “top-level” scope, it works fine.
Can someone please explain why and how can I make this work in a package?