HTML and CSS Reference
In-Depth Information
Once the date has been identified it will be parsed using the date library from a string to a
date. We will then compare that date to today: if the result is less than 0 the date is in the
past, and we add the overdue class.
If the date is not in the past, we see if it is less than or equal to 2 days from now. If so we
add the warning class.
We could have written JavaScript to perform these operations without importing a date lib-
rary, but our code would have been less succinct, and open to bugs. The advantage of using
a library is that it has undergone testing by everyone who has used it; therefore the level of
quality tends to be high.
We now need to invoke this when the table is loaded:
loadTasks : function() {
storageEngine.findAll('task', function(tasks) {
$.each(tasks, function(index, task) {
$('#taskRow').tmpl(task).appendTo( $(taskPage).find( '#tblTasks tbody'));
});
taskCountChanged();
renderTable();
}, errorLogger);
}
If you now add tasks that are overdue, or due within the next 2 days, they should be
rendered appropriately.
Search WWH ::




Custom Search