Conversation
This adds todo webpage
This removes intetnal js DevCANS#1
Rohitrajak1807
left a comment
There was a problem hiding this comment.
@sauravkr818 I have added some comments. Please have a look
1. Building a To-Do List Without Framework/submission/index.html
Outdated
Show resolved
Hide resolved
|
Okay @Rohitrajak1807 @deepakgupta191199 bhaiya. |
This updates the UI and removes the bug DevCANS#1
|
|
Okay I will fix it soon. |
This fixes the issue of marking checkbox and then reloading DevCANS#1
| <strong>Please add any item</strong> | ||
| <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> | ||
| </div>`; | ||
| $("#save-info").html(clearInfo); |
There was a problem hiding this comment.
You should avoid the use of JQuery or any other library for a simple task which can be easily done without it.
There was a problem hiding this comment.
I used jQuery just to display confirmation messages to the user. Should I remove the display messages and keep it simple?
There was a problem hiding this comment.
Okay bhaiya give me some time.
| todoList.length > 0 // if array length is null then do not show confirm msg. | ||
| ? `${confirm("Are you sure you want to delete your all items")} | ||
| ${localStorage.removeItem("todoList")} | ||
| ${(todoList = [])} // array made empty | ||
| ${renderList()}` | ||
| : ""; |
There was a problem hiding this comment.
You should not do this. This is not at all readable and may not get properly formatted by eslint or other formatters.
Use a simple if condition.
| `${localStorage.removeItem("todoList")} | ||
| ${(todoList = [])} | ||
| ${renderList()}` |
There was a problem hiding this comment.
There is no need to call functions inside template strings unless you are storing it in a variable.
And these statements do not return anything so it is of no use to call it in a template string
| try { | ||
| if (localStorage.getItem("todoList")) { | ||
| todoList = JSON.parse(localStorage.getItem("todoList")); | ||
| renderList(); | ||
| } | ||
| } catch (e) { | ||
| console.log(e); | ||
| } |
There was a problem hiding this comment.
You can use this code just after defining the todoList array.
| } | ||
| }; | ||
|
|
||
| document.getElementById("todo-form").addEventListener("submit", (event) => { |
There was a problem hiding this comment.
Define event listeners at the end.
This adds todo webpage
UI completed
checkout here https://sauravkr818-todo.netlify.app/