adamfarver/shop_list — pull request #1 by eddieospaghettio (2014-10-14 20:03:41+00:00)
Title: Strikethrough works now

You've got to bind your click event for p.item on to a higher level DOM element like 'main'.

You don't want to do ('.item').on('click'... because it will only bind to the first .item it finds when the document loads. Any subsequent .item elements that are created will be ignored.

Instead bind your .on('click' event to a higher level DOM element like the whole main section. Like this:

//Bind the click even to a higher level element.
$('main').on('click', 'li', function() {
//'this' is the 'li' we just clicked, within it find an element with class 'item' and toggle it's class
$(this).find('.item').toggleClass('done');
});

This way any time we click an 'li' element within 'main' it will search within that clicked 'li' element for a '.item' element and toggle it's class.