对话框

对话框可以通过hx-prompthx-confirm属性触发。这些对话框会在触发AJAX请求的用户交互时出现,但只有在对话框被接受后才会发送请求。

<div>
  <button class="btn primary"
          hx-post="/submit"
          hx-prompt="输入字符串"
          hx-confirm="确定吗?"
          hx-target="#response">
    提示提交
  </button>
  <div id="response"></div>
</div>

用户在提示对话框中输入的值会通过HX-Prompt头部发送到服务器。在这个例子中,服务器只是简单地回显用户输入。

用户输入了 <i>${response}</i>
服务器请求 ↑ 显示

🔗演示