11. TODOS IN COLLECTIONS
Tasks = new Mongo.Collection("tasks");
if (Meteor.isClient) {
// This code only runs on the client
Template.body.helpers({
tasks: function () {
return Tasks.find({});
}
});
}
13. EINGABEFORMULAR HINZUFÜGEN
<form class="new-task">
<input type="text"
name="text"
placeholder="Type to add new tasks" />
</form>
14. EVENTS
Template.body.events({
"submit .new-task": function (event) {
var text = event.target.text.value;
Tasks.insert({
text: text,
createdAt: new Date() // current time
});
// Clear form
event.target.text.value = "";
// Prevent default form submit
return false;
}
});