Created
February 5, 2015 15:28
-
-
Save al-the-x/fdb234951a0092e8e59d 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) { | |
| 'use strict'; | |
| // Your starting point. Enjoy the ride! | |
| $(document).ready(function(){ | |
| $('#new-todo').on('keypress', function (e) { | |
| if(e.which == 13) { | |
| var newTask = $('#new-todo').val(); | |
| console.log(newTask); | |
| var newItem = | |
| '<li>' + | |
| '<div class="view">' + | |
| '<input class="toggle" type="checkbox">' + | |
| '<label>' + newTask + '</label>' + | |
| '<button class="destroy"></button>' | |
| '</div>' + | |
| '<input class="edit" value="'+ newTask +'">' + | |
| '</li>'; | |
| $('#todo-list').append(newItem); | |
| $('#new-todo').val(''); | |
| var lengthOfToDo = $('#todo-list li').length; | |
| $('#todo-count strong').text(lengthOfToDo); | |
| } | |
| $('.destroy').on('click', function() { | |
| $(this).parent().parent().remove(); | |
| var lengthOfToDo = $('#todo-list li').length; | |
| $('#todo-count strong').text(lengthOfToDo); | |
| }); | |
| }); | |
| $('#todo-list').on('dblclick', '.view', function(event){ | |
| // alert(event.type); | |
| // Add class ".editing" to my parent <li>... | |
| // ???? | |
| }); | |
| // var toggleAll = $('#toggle-all'); | |
| // toggleAll.on('click', function(){ | |
| // $('.toggle').attr('checked', true); | |
| // $('li').toggleClass('completed'); | |
| }); | |
| })(window); | |
| // $(document).ready(function(){ | |
| // $('.toggle').on('click', function(){ | |
| // $(this).attr('checked'); | |
| // }) | |
| // }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment