hx-include

hx-include 属性允许你在 AJAX 请求中包含其他元素值。此属性的值可以是:

¥The hx-include attribute allows you to include additional element values in an AJAX request. The value of this attribute can be:

以下是包含单独输入值的示例:

¥Here is an example that includes a separate input value:

<div>
    <button hx-post="/register" hx-include="[name='email']">
        Register!
    </button>
    Enter email: <input name="email" type="email"/>
</div>

这有点牵强,因为你通常会将这两个元素都放在 form 中并自动提交值,但它演示了这个概念。

¥This is a little contrived as you would typically enclose both of these elements in a form and submit the value automatically, but it demonstrates the concept.

请注意,如果你包含非输入元素,则将包含该元素中包含的所有输入元素。

¥Note that if you include a non-input element, all input elements enclosed in that element will be included.

注释

¥Notes