mswanson-me / to-do

A vanilla JS to do list.
https://to-do.mswanson.me
0 stars 0 forks source link

Deleting items resets strikethroughs #3

Closed mswanson-me closed 6 years ago

mswanson-me commented 6 years ago

Currently, a completed item is indicated by a strikethrough, which is implemented with a simple css class toggle. When an item is deleted, the list reloads, which causes the strikethrough class to be cleared.

List data structure does include a Boolean indicating completed status.

The functionality needs to be fixed to where the strikethrough class is applied based on the Boolean value in the structure, so items will remain checked off even when the list is rerendered.

mswanson-me commented 6 years ago

React might be useful here.

mswanson-me commented 6 years ago

Also addClass can be overloaded with a function. Data structure has a Boolean value describing if items are checked off or not. Could if statement in a function to look for Boolean and set the strikethrough class conditionally.

mswanson-me commented 6 years ago

Fixed with template string and ternary operator.

https://github.com/mswanson-me/stay-focused/commit/e228adbbfc3559d4563d31ac2184aae57557b8ed