I'm developing a TaskList to understand how MeteorJS
works.
In the application the user can enter the name of the task, how many hours it will spend in it and when it will perform it.
The system returns a list with all the tasks of the user and the sum of the hours of the tasks, ie the problem, how to add the hours of the tasks using MeteorJS
?
Code to enter the task.
Template.new.events({
"submit form" : function(e, template) {
e.preventDefault();
var InputName = $("#taskName");
var taskName = InputName.val();
var InputTime = $("#taskTime");
var taskTime = InputTime.val();
var InputDate = $("#taskDate");
var taskDate = InputDate.val();
var item = {name: taskName, time: taskTime , date: taskDate };
Task.insert(item);
InputName.val();
}
});
Code to list the tasks
Template.list.helpers({
tasklist: function() {
return Task.find({});
}
});
View Code
{{#each tasklist}}
<tr>
<td id="time">
{{time}}
</td>
<td>
{{name}}
</td>
<td>
{{date}}
</td>
<td>
<button class="btn remove-btn ">Remove</button>
</td>
</tr>
{{/each}}
<p class="text-center total " id="resultado">
Total Hours:
</p>