A_L
A_L

Reputation: 1146

Meteor method not found

I have public.js in the /server folder with this code:

Meteor.methods({
    foo: function (myarg) {
        return myarg;
    }
});

I am hooking a button click event in my template script like this:

Template.myTemplate.events({
    'click #clickme' : function() {
        Meteor.call(foo, 'ola', function(error, result) {
            alert(result);
        });
    }
});

I can't see what is wrong here, as I get the message 'Uncaught ReferenceError: foo is not defined' when clicking my button

Upvotes: 0

Views: 485

Answers (1)

Sjoerd Visscher
Sjoerd Visscher

Reputation: 12010

Try Meteor.call('foo', ...), you need to pass the name of the function as a string.

Upvotes: 1

Related Questions