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

[14기 최재원] step1 돔 조작과 이벤트 핸들링으로 메뉴 관리하기 #250

Open
wants to merge 4 commits into
base: maddrake220
Choose a base branch
from

Conversation

maddrake220
Copy link

안녕하세요!

뉴비 개발자 최재원 입니다.

반갑습니다.

@maddrake220 maddrake220 changed the title [문벅스 14기] step1 카페메뉴 만들기 [14기 최재원] step1 카페메뉴 만들기 Jul 11, 2022
@maddrake220
Copy link
Author

안녕하세요

@maddrake220 maddrake220 changed the title [14기 최재원] step1 카페메뉴 만들기 [14기 최재원] step1 돔 조작과 이벤트 핸들링으로 메뉴 관리하기 Jul 17, 2022
@maddrake220 maddrake220 marked this pull request as draft July 18, 2022 07:32
@maddrake220 maddrake220 marked this pull request as ready for review July 18, 2022 07:32
import { generateId } from "./utils/index.js";

const menuName = document.querySelector("#espresso-menu-name");
const menuForm = document.querySelector("#espresso-menu-form");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 강의에서 봤는데요, const $ = selector = document.querySelector(selector)와 같이 util 함수로 빼놓으면 편리하다고 합니다ㅎㅎ

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오호 좋은 정보 감사드립니다!


const menuCount = document.querySelector(".menu-count");

export function MenuList() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

components와 containers를 나눈 기준이 궁금합니당! 🤓 여러 component를 사용하는 요소가 container인 건가요..? (제 추측...)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presentional & Container 패턴을 사용하려고 이렇게 폴더 구조를 나눴고,
추후 리팩토링 과정을 통해 명확하게 분리하려고 합니다!

Comment on lines +30 to +35
setTimeout(() => {
const edit = document.querySelector(`#edit-item-${id}`);
const remove = document.querySelector(`#remove-item-${id}`);
edit.addEventListener("click", onClickEdit);
remove.addEventListener("click", onClickDelete);
}, 10);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setTimeout 사용한 건 동적으로 생성된 요소들에 eventListener를 추가하기 위해서인가용??
만약 그런거라면 이벤트 위임을 사용해서 부모 요소에 eventListner를 설정해둬도 될 것 같아요!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋은 방법이네요!
리팩토링 할 때 참고할게요!

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

2 participants