javascript - Meteor method giving error -
i new meteor. trying call meteor.method('addtask') event helper , keep getting error: "error invoking method 'addtask': method 'addtask' not found [404]". put code below:
template.add_task.events({ 'submit .js-emoticon': function(event){ event.preventdefault(); // console.log('clicked'); // var text = event.target.text.value; // $('#text_display').html(text); // $('#text_display').emoticonize(); meteor.call("addtask"); }
});
and meteor.method here:
meteor.methods({ 'addtask':function(){ var task = event.target.text.value; items.insert({ created:new date().tolocaledatestring("en-us"), task:task }); console.log(task); }
});
both on main.js in client folder. have tried put method on server/main.js , error: "error invoking method 'addtask': internal server error [500]".
if on client log value of #text console on server doesn't that.
as said have been learning meteor , researched way it. missing , can't figure out. appreciated.
you trying @ dom element server code. need element on client , pass method, can put in /lib
folder latency compensation if wish.
client:
template.add_task.events({ 'submit .js-emoticon': function(event){ event.preventdefault(); var task = event.target.text.value; meteor.call("addtask",task); } });
server:
meteor.methods({ 'addtask':function(task){ check(task,string); items.insert({ created: new date(), task: task }); console.log(task); } });
you never want convert dates strings when persist them in mongo. makes searching on dates impossible.
Comments
Post a Comment