-
Notifications
You must be signed in to change notification settings - Fork 375
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
base: maddrake220
Are you sure you want to change the base?
[14기 최재원] step1 돔 조작과 이벤트 핸들링으로 메뉴 관리하기 #250
Conversation
안녕하세요 |
import { generateId } from "./utils/index.js"; | ||
|
||
const menuName = document.querySelector("#espresso-menu-name"); | ||
const menuForm = document.querySelector("#espresso-menu-form"); |
There was a problem hiding this comment.
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 함수로 빼놓으면 편리하다고 합니다ㅎㅎ
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
components와 containers를 나눈 기준이 궁금합니당! 🤓 여러 component를 사용하는 요소가 container인 건가요..? (제 추측...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Presentional & Container 패턴을 사용하려고 이렇게 폴더 구조를 나눴고,
추후 리팩토링 과정을 통해 명확하게 분리하려고 합니다!
setTimeout(() => { | ||
const edit = document.querySelector(`#edit-item-${id}`); | ||
const remove = document.querySelector(`#remove-item-${id}`); | ||
edit.addEventListener("click", onClickEdit); | ||
remove.addEventListener("click", onClickDelete); | ||
}, 10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setTimeout 사용한 건 동적으로 생성된 요소들에 eventListener를 추가하기 위해서인가용??
만약 그런거라면 이벤트 위임을 사용해서 부모 요소에 eventListner를 설정해둬도 될 것 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋은 방법이네요!
리팩토링 할 때 참고할게요!
안녕하세요!
뉴비 개발자 최재원 입니다.
반갑습니다.