hx-vals

hx-vals 속성을 μ‚¬μš©ν•˜λ©΄ AJAX μš”μ²­κ³Ό ν•¨κ»˜ μ œμΆœν•  λ§€κ°œλ³€μˆ˜λ₯Ό μΆ”κ°€ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

기본적으둜 이 μ†μ„±μ˜ 값은 JSON (JavaScript Object Notation) ν˜•μ‹μ˜ 이름-ν‘œν˜„μ‹ κ°’ λͺ©λ‘μž…λ‹ˆλ‹€.

hx-valsκ°€ 주어진 값을 ν‰κ°€ν•˜λ„λ‘ ν•˜λ €λ©΄ κ°’ μ•žμ— javascript: λ˜λŠ” js: λ₯Ό 뢙이면 λ©λ‹ˆλ‹€.

  <div hx-get="/example" hx-vals='{"myVal": "My Value"}'>Get Some HTML, Including A Value in the Request</div>

  <div hx-get="/example" hx-vals='js:{myVal: calculateValue()}'>Get Some HTML, Including a Dynamic Value from Javascript in the Request</div>

ν‰κ°€λœ μ½”λ“œλ₯Ό μ‚¬μš©ν•˜λ©΄ event 객체에 μ•‘μ„ΈμŠ€ν•  수 μžˆμŠ΅λ‹ˆλ‹€. 이 μ˜ˆμ œμ—λŠ” μž…λ ₯ λ‚΄μ—μ„œ λ§ˆμ§€λ§‰μœΌλ‘œ μž…λ ₯ν•œ key의 값이 ν¬ν•¨λ©λ‹ˆλ‹€.

  <div hx-get="/example" hx-trigger="keyup" hx-vals='js:{lastKey: event.key}'>
    <input type="text" />
  </div>

Security Considerations

Notes