0
下面有一個把手幫手,它顯示了選定的玩家威脅。它的工作原理。在方法中使用Meteor.users.findOne If語句
Handlebars.registerHelper('sthreat', function() {
var sthreat = Meteor.users.findOne({_id: Session.get('selectedPlayer')}, {threat: 1});
return sthreat;
});
但是下面的按鈕(客戶端)和方法(在服務器上)的假設,以檢查球員繼續前5個或更多的威脅,但他們沒有工作。
'click input.increment': function(){
var selectedThreat = Meteor.users.findOne({_id: Session.get('selectedPlayer')}, {threat: 1});
Meteor.call('incclick',selectedThreat);
},
incclick: function (selectedThreat) {
if(selectedThreat <= 4) {
} else {
Meteor.users.update({_id: Session.get('selectedPlayer')}, {$inc: {'threat': -5}});
Meteor.users.update({_id: this.userId}, {$inc: {'threat': 5}});
}
},
我想如果我能得到值顯示在助手中,我應該能夠在方程中使用它。有什麼我在這裏失蹤?
當我做了這個樣子了一個錯誤。錯誤調用方法'incclick':內部服務器錯誤[500] –
@JonPotts這是由於您的方法調用中無關的錯誤。你應該檢查你的服務器端控制檯的細節。我懷疑這是'Session',它不受服務器端支持。 – Akshat