1
I’m developing a Tasklist to understand how MeteorJS
works.
In the application the user can enter the task name, how many hours he will spend on it and when he will perform it.
The system returns a list of all the user tasks and the sum of the tasks' hours, here is the problem, how to sum up the tasks' hours using the 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 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>
What format are you entering the date/time in the database?
– Lucas Fontes Gaspareto