I'm working through David's tutorial on Meteor at http://meteortips.com/.
How do I insert an integer instead of string on form submit?
I think the following line needs to clarify that it's an integer, but I'm not sure how.
var playerScoreVar = event.target.playerScore.value;
Here's my whole code.
Template.addPlayerForm.events({
'submit form': function(event){
event.preventDefault();
var playerNameVar = event.target.playerName.value;
var playerScoreVar = event.target.playerScore.value;
PlayersList.insert({
name: playerNameVar,
score: playerScoreVar,
});
event.target.playerName.value = ""
event.target.playerScore.value = ""
}
});
Just convert it to an integer prior to the
insert
:or
You can see the differences explained here;