Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTyler Herbst
11,763 PointsI'm not seeing the console logs when I click on the checkboxes and buttons...where did I go wrong?
//Problem: User interaction doesn't provide desired results.
//Solution: Add interactivity so the user can manage daily tasks.
var taskInput = document.getElementById("new-task"); //new-task
var addButton = document.getElementsByTagName("button")[0]; //first button
var incompleteTasksHolder = document.getElementById("incomplete-tasks"); //incomplete-tasks
var completedTasksHolder = document.getElementById("completed-tasks"); //completed-tasks
//Add a new task
var addTask = function() {
console.log("Add task...");
//When the button is pressed
//Create a new list item with the text from #new-task:
//Input (checkbox)
//Label
//Input (text)
//button.edit
//button.delete
//Each element needs to be modified and appended
}
//Edit an existing task
var editTask = function() {
console.log("Edit task...");
//When the edit button is pressed
//if the class of the parent is .editMode
//Switch from .editMode
//label text become the input's value
//else
//Switch to .editMode
//input value becomes the label's text
//Toggle .editMode on the parent
}
//Delete an existing task
var deleteTask = function() {
console.log("Delete task...");
//when the Delete button is pressed
//Remove the parent list item from the ul
}
//Mark a task as complete
var taskCompleted = function() {
console.log("Task Complete...");
//When the Checkbox is checked
//Append the task list item to the #completed-tasks
}
//Mark a task as incomplete
var taskIncomplete = function() {
console.log("Task Incomplete...");
//When the checkbox is unchecked
//Append the task list item to the #complete-tasks
}
var bindTaskEvents = function(taskListItem, checkBoxEventHandler) {
console.log("Bind list item events");
//select taskListItem's children
var checkBox = taskListItem.querySelector("input[type=checkbox]");
var editButton = taskListItem.querySelector("button.edit");
var deleteButton = taskListItem.querySelector("button.delete");
//bind editTask to edit button
editButton.onclick = editTask;
//bind deleteTask to delete button
deleteButton.onclick = deleteTask;
//bind checkBoxEventHandler to checkbox
checkBox.onchange = checkBoxEventHandler;
}
//Set the click handler to the addTask function
addButton.onclick = addTask;
//cycle over incompleteTasksHolder ul list items
for (var i = 0; i < incompleteTasksHolder.children.length; i++) {
//bind events to list item's children (taskCompleted)
bindTaskEvents(incompleteTasksHolder.children[i], taskCompleted);
}
//cycle over completedTasksHolder ul list items
for (var i = 0; i < completedTasksHolder.children.length; i++) {
//bind events to list item's children (taskIncomplete)
bindTaskEvents(completedTasksHolder.children[i], taskIncomplete);
}
2 Answers
Marcus Parsons
15,719 PointsHey Tyler,
The code you pasted is correct. If you've saved the document and then refreshed the page, you should be seeing the console.log output in your console. If you know they are saved and you've refreshed the page, you might want to clear your recent history, including your cache. The browser might be trying to use a cached script. If none of that works, there may be some spelling mistakes in your HTML file with the references in the JavaScript file, so you should come back and post a snapshot of your workspace. If you don't know how to do that, check this link out: http://www.teamtreehouse.com/forum/workspace-snapshots
Tyler Herbst
11,763 PointsWow, you were right. Pretty annoying that saving and reopening/refreshing wasn't enough. Thanks
Marcus Parsons
15,719 PointsI'm still learning about how and when browsers cache scripts, but it's definitely something to keep in mind when you get stuck like that haha You're welcome man. Happy Coding!