Last active
August 29, 2015 14:21
-
-
Save al-the-x/d3375b441b22198573f2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (window) { // IIFE: Immediately Invoked Function Expression | |
'use strict'; // For bonus points, what does this do? | |
// CONTROLLER FOR: I can add a task to my list... | |
// 1. What event should I be listening for? keydn, keyup, keypress | |
// 2. What element makes sense to listen for that event? input.new-todo | |
// 3. What do I need to do when that event fires? | |
// GIVEN an HTML element <input class="new-todo"> | |
var newTodoInput = document.querySelector('input.new-todo'); | |
// WHEN the user types a task | |
newTodoInput.addEventListener('keyup', function addTodoController(event){ | |
if ( event.keyCode === 13 ){ // AND presses the "Enter" key | |
console.log('sanity check!'); | |
// THEN: | |
// TODO Save the thing to remember (task) to the list of things to remember (taskList) | |
// TODO Remove the thing to remember (task) from the "What needs to be done?" box (input.new-todo) | |
// TODO Update the number of tasks in the footer... | |
// TODO Add a new task (ul.todo-list > li) to the list of tasks _in the display_ (ul.todo-list) | |
} | |
}); // END addEventListener(addTodoController) | |
})(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment