Tabs (Using HATEOAS)

이 μ˜ˆλŠ” htmxλ₯Ό μ‚¬μš©ν•˜μ—¬ 탭을 κ΅¬ν˜„ν•˜λŠ” 것이 μ–Όλ§ˆλ‚˜ μ‰¬μš΄μ§€ λ³΄μ—¬μ€λ‹ˆλ‹€.
μ• ν”Œλ¦¬μΌ€μ΄μ…˜ μƒνƒœμ˜ μ—”μ§„μœΌλ‘œμ„œμ˜ ν•˜μ΄νΌν…μŠ€νŠΈμ˜ 원칙에 따라 μ„ νƒν•œ 탭은 μ• ν”Œλ¦¬μΌ€μ΄μ…˜ μƒνƒœμ˜ 일뢀가 λ©λ‹ˆλ‹€.
λ”°λΌμ„œ μ• ν”Œλ¦¬μΌ€μ΄μ…˜μ—μ„œ 탭을 ν‘œμ‹œν•˜κ³  μ„ νƒν•˜λ €λ©΄ λ°˜ν™˜λœ HTML에 νƒ­ λ§ˆν¬μ—…μ„ ν¬ν•¨ν•˜κΈ°λ§Œ ν•˜λ©΄ λ©λ‹ˆλ‹€.
이 방법이 μ• ν”Œλ¦¬μΌ€μ΄μ…˜ μ„œλ²„ λ””μžμΈμ— μ ν•©ν•˜μ§€ μ•Šμ€ 경우 μžλ°”μŠ€ν¬λ¦½νŠΈλ‘œ νƒ­ μ„ νƒν•˜κΈ°λ₯Ό μ‚¬μš©ν•  μˆ˜λ„ μžˆμŠ΅λ‹ˆλ‹€.

#Example Code (Main Page)

메인 νŽ˜μ΄μ§€μ—λŠ” 초기 탭을 DOM에 λ‘œλ“œν•˜λŠ” λ‹€μŒ HTML이 ν¬ν•¨λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.

<div id="tabs" hx-get="/tab1" hx-trigger="load delay:100ms" hx-target="#tabs" hx-swap="innerHTML"></div>

#Example Code (Each Tab)

이후 νƒ­ νŽ˜μ΄μ§€μ—λŠ” λͺ¨λ“  탭이 ν‘œμ‹œλ˜κ³  μ„ νƒν•œ 탭이 그에 따라 κ°•μ‘° ν‘œμ‹œλ©λ‹ˆλ‹€.

<div class="tab-list" role="tablist">
	<button hx-get="/tab1" class="selected" role="tab" aria-selected="true" aria-controls="tab-content">Tab 1</button>
	<button hx-get="/tab2" role="tab" aria-selected="false" aria-controls="tab-content">Tab 2</button>
	<button hx-get="/tab3" role="tab" aria-selected="false" aria-controls="tab-content">Tab 3</button>
</div>

<div id="tab-content" role="tabpanel" class="tab-content">
	Commodo normcore truffaut VHS duis gluten-free keffiyeh iPhone taxidermy godard ramps anim pour-over.
	Pitchfork vegan mollit umami quinoa aute aliquip kinfolk eiusmod live-edge cardigan ipsum locavore.
	Polaroid duis occaecat narwhal small batch food truck.
	PBR&B venmo shaman small batch you probably haven't heard of them hot chicken readymade.
	Enim tousled cliche woke, typewriter single-origin coffee hella culpa.
	Art party readymade 90's, asymmetrical hell of fingerstache ipsum.
</div>
Server Requests ↑ Show

πŸ”—Demo

Commodo normcore truffaut VHS duis gluten-free keffiyeh iPhone taxidermy godard ramps anim pour-over. Pitchfork vegan mollit umami quinoa aute aliquip kinfolk eiusmod live-edge cardigan ipsum locavore. Polaroid duis occaecat narwhal small batch food truck. PBR&B venmo shaman small batch you probably haven't heard of them hot chicken readymade. Enim tousled cliche woke, typewriter single-origin coffee hella culpa. Art party readymade 90's, asymmetrical hell of fingerstache ipsum.