Modal Dialogs in Bootstrap

λ§Žμ€ CSS νˆ΄ν‚·μ—λŠ” λͺ¨λ‹¬ λŒ€ν™” μƒμžλ₯Ό λ§Œλ“€κΈ° μœ„ν•œ μŠ€νƒ€μΌ(및 μžλ°”μŠ€ν¬λ¦½νŠΈ)이 ν¬ν•¨λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€. 이 μ˜ˆλŠ” λΆ€νŠΈμŠ€νŠΈλž©μ—μ„œ μ œκ³΅ν•˜λŠ” 원본 JavaScript와 ν•¨κ»˜ HTMXλ₯Ό μ‚¬μš©ν•˜λŠ” 방법을 λ³΄μ—¬μ€λ‹ˆλ‹€.

λ¨Όμ € λŒ€ν™” μƒμžλ₯Ό νŠΈλ¦¬κ±°ν•˜λŠ” λ²„νŠΌκ³Ό λ§ˆν¬μ—… ν•˜λ‹¨μ— λŒ€ν™” μƒμžκ°€ λ‘œλ“œλ˜λŠ” DIVκ°€ μžˆμŠ΅λ‹ˆλ‹€:

<button
    hx-get="/modal"
    hx-target="#modals-here"
    hx-trigger="click"
    data-bs-toggle="modal"
    data-bs-target="#modals-here"
    class="btn primary">Open Modal</button>

<div id="modals-here"
    class="modal modal-blur fade"
    style="display: none"
    aria-hidden="false"
    tabindex="-1">
    <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
        <div class="modal-content"></div>
    </div>
</div>

이 λ²„νŠΌμ„ ν΄λ¦­ν•˜λ©΄ /modal에 GET μš”μ²­μ„ λ³΄λƒ…λ‹ˆλ‹€.
μ‘λ‹΅μ˜ λ‚΄μš©μ€ #modals-here DIV μ•„λž˜μ˜ DOM에 μΆ”κ°€λ©λ‹ˆλ‹€.

μ„œλ²„λŠ” λΆ€νŠΈμŠ€νŠΈλž©μ˜ ν‘œμ€€ λͺ¨λ‹¬μ„ μ•½κ°„ μˆ˜μ •ν•œ λ²„μ „μœΌλ‘œ μ‘λ‹΅ν•©λ‹ˆλ‹€.

<div class="modal-dialog modal-dialog-centered">
  <div class="modal-content">
    <div class="modal-header">
      <h5 class="modal-title">Modal title</h5>
    </div>
    <div class="modal-body">
      <p>Modal body text goes here.</p>
    </div>
    <div class="modal-footer">
      <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
    </div>
  </div>
</div>
Server Requests ↑ Show

πŸ”—Demo