Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor UI updating #7

Merged
merged 13 commits into from May 11, 2022
Merged

Refactor UI updating #7

merged 13 commits into from May 11, 2022

Conversation

yosefHesham
Copy link
Owner

Brief of What Changed:

I figured out another way of updating UI, instead of re-rendering the list after every modification.


Changes Made:

  • In the add method, I add all needed event listeners to each new item before I append it to the DOM.
  • Created configureNewAddedItem module.
  • Created a getElement module.
  • Created a module for event listeners.
  • In the delete, I am not depending on the class of the element anymore, I use the index of the current child node from the list:

more on that ⏬
const list = document.querySelector('.list'); const arrayNodes = Array.from(list.childNodes); removeToDo(arrayNodes.indexOf(parent) + 1);

by that, I managed to stop the headache of re-rendering the items and adding a loop through them every time to add event listeners, and the code is more clean.

@yosefHesham yosefHesham merged commit c3f093c into main May 11, 2022
@yosefHesham yosefHesham deleted the refactor-ui-updating branch May 11, 2022 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant