Reputation: 197
IM trying out Meteor ToDo-list tutorial but I have problem where I have a form and I should be able to insert the values into the database but it doesn't work. When I hit enter nothing happens.
Here my my html:
<head>
<title>Todo list</title>
</head>
<body>
<div class="container">
<header>
<h1>Tee asjad ära!</h1>
<form class="new-task">
<input type="text" placeholder="Type to add new tasks" />
</form>
</header>
<ul>
{{#each tasks}}
{{> task}}
{{/each}}
</ul>
</div>
</body>
<template name="task">
<li>{{text}}</li>
</template>
here is the .js file:
Tasks = new Mongo.Collection("tasks");
if (Meteor.isClient) {
//see kood jookseb ainult kliendipoolel
Template.body.helpers({
tasks: function () {
return Tasks.find({});
}
});
Template.body.events({
"submit .new-task": function (event) {
var text = event.target.text.value;
Tasks.insert({
text: text,
createdAt: new Date()
});
event.target.text.value = "";
return false;
}
});
}
When I enter values from command line to the database it works fine.
Upvotes: 0
Views: 591
Reputation: 6147
Your input is missing name="text"
, which is the attribute that lets you access the value through event.target.text.value
.
Were you getting an error in the JavaScript console in your browser?
Upvotes: 1