Created
April 21, 2017 03:34
-
-
Save rachel-yankelevitz/b46016206eab9bfb6ed7399c9508475e to your computer and use it in GitHub Desktop.
HW 2
This file contains 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
$(document).ready(function(){ | |
var todoCollection = []; | |
$(".main, .footer").hide(); | |
$(".new-todo").keypress(function(e) { | |
// enter key's key number is 13 | |
if (e.which === 13 && $(this).val().length > 1){ | |
var todoInput = $(".new-todo").val(); | |
$.trim(todoInput); | |
var todoId = _.uniqueId(); | |
var todoObj = { | |
id: todoId, | |
content: todoInput, | |
completed: false | |
}; | |
todoCollection.push(todoObj); | |
console.log(todoCollection); | |
var listItem = "<li data-id=" + todoId + ">" + todoInput + "</li>"; | |
$(".main, .footer").show(); | |
$(".todo-list").append(listItem); | |
//mark all as complete | |
$(".clear-completed").bind("click", function() { | |
$("input[type=text], textarea").val(""); | |
}); | |
} | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thoughts,
https://gist.github.com/rachel-yankelevitz/b46016206eab9bfb6ed7399c9508475e#file-app-js-L10
$(this).val().length > 1
, this part should be 0, not 1 for anything more than 0. You're not adding a new item if someone just typed inone character
.https://gist.github.com/rachel-yankelevitz/b46016206eab9bfb6ed7399c9508475e#file-app-js-L22
<li>
item is missing a good chunk of its meat. Take a look at https://github.com/ga-students/JS-NYC-3.20.17/blob/master/homeworks/homework-02/index.html#L32-L39 and add the necessary parts to this.Rachel! There isn't much improvement over what we worked on after the class. I know you know you could've done more than this :/
2/4.
-Stephen