Meteor.call() is not working within Template events


#1

I have created a template name foo and bind some events like:

 Template.foo.events({
     'submit #identity': function(event, template) {
      Meteor.call("methodName", function ( error,result) {
       
       if (error) {
      console.log(error);
          }
     console.log(result)
     });

})

I am not able to figure out why this meteor.call() method is working out side of this template events but its doesn’t work inside this template event block.


#2

That looks like it should work. Are you sure your event is being run?


#3

Yea, this should work. Just that we haven’t seen the template yet. Check for the id #identity and that you’re attaching the events to the right template. In this case, any element with attribute id=“identity” should be in the foo template.


#4

There is a missing a single curly brace (}) on the line after }); (to close the function's BlockStatement) which would trigger a SyntaxError but otherwise this should work.