【问题标题】:Clear all input fields on submit using Hyperscript使用 Hyperscript 清除提交时的所有输入字段
【发布时间】:2022-01-08 23:41:00
【问题描述】:

我正在使用 htmx 和超脚本,我希望在提交时清除以下表单中的所有输入字段:

<form hx-post="/example" hx-target="#table tbody" hx-swap="beforeend"
      _="<what should I write here??>">
        <label class="control-label" for="firstNameInput">First Name</label>
        <input id="firstNameInput" name="firstName" class="form-control" type="text" required placeholder="John"/>
        
        <label class="control-label" for="lastNameInput">Last Name</label>
        <input id="lastNameInput" name="lastName" class="form-control" type="text" required placeholder="Doe"/>
        <button class="btn btn-primary">Add User</button>
    </div>
</form>

我尝试将&lt;what should I write here??&gt; 替换为例如on submit put '' into &lt;input/&gt; 和 on submit put '' into &lt;input[value]/&gt; 以及许多其他组合,但我无法完成这项工作。

问:如何在提交表单时清除所有输入字段?

【问题讨论】:

    标签: htmx hyperscript


    【解决方案1】:

    试试on htmx:afterRequest reset() me

    【讨论】:

    猜你喜欢
    • 2022-01-09
    • 2020-09-03
    • 1970-01-01
    • 2023-03-09
    • 1970-01-01
    • 2020-11-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多