Meteor.call(…)导致刷新页面

我正在开发一个非常简单的使用Meteor的投票应用程序。

voteapp.meteor.com

点击投票button(select一个选项后出现)后,页面刷新。

点击事件:

Template.poll.events({ "click input.inc": function (event) { // Prevent default browser form submit event.preventDefault(); Meteor.call('voteForAnswer', Session.get("selectedanswer"), function (error, result) { if (error) { Session.set("voteError", error.reason); } else { Session.set("voteError", null); Session.set("selectedpoll", result); } }); } }); 

Meteor.callfunction:

 'voteForAnswer': function (id, vote) { var answer = Answers.findOne(id); var poll = Polls.findOne(answer.poll); if (poll && answer) { Answers.update(answer, { $inc: { score: 1 } }, function (error) { if (error) { throw new Meteor.Error(411, "Answer could not be updated."); } }); Polls.update(poll, { $inc: { sum: 1 }, $set: { lastActivity: new Date() } }, function (error) { if (error) { throw new Meteor.Error(411, "Poll could not be updated. " + poll.name); } }); poll = Polls.findOne(poll._id); var answers = Answers.find({ poll: poll._id }).fetch(); answers.forEach(function (ans) { ans.score && Answers.update(ans, { $set: { percent: Math.round((parseInt(ans.score) / parseInt(poll.sum)) * 100) } }); }); poll.answers = Answers.find({ poll: poll._id }, { sort: { score: -1 } }).fetch(); } return poll; } 

也:

 if (Meteor.isClient) { Meteor.subscribe("polls"); Meteor.subscribe("answers"); 

和:

 if (Meteor.isServer) { Meteor.publish("polls", function () { return Polls.find(); }); Meteor.publish("answers", function () { return Answers.find(); }); } 

       

网上收集的解决方案 "Meteor.call(…)导致刷新页面"