Skip to content

Instantly share code, notes, and snippets.

@al-the-x
Created February 5, 2015 15:28
Show Gist options
  • Select an option

  • Save al-the-x/fdb234951a0092e8e59d to your computer and use it in GitHub Desktop.

Select an option

Save al-the-x/fdb234951a0092e8e59d to your computer and use it in GitHub Desktop.
(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