0

我正在尝试使用 Htmx 添加一个新的表格行。通过单击“添加新行”按钮,应将新行添加到表中。我无法将 secondary_hx.html 中的行添加到表中,而是导致三个表单彼此相邻,而没有 or 。任何帮助,将不胜感激。先感谢您。我的代码是这样的:

主.html:

<table id="myTable">
  <thead>
      <tr>
          <th>1</th>
          <th>2</th>
          <th>3</th>
      </tr>
  </thead>
  <tbody id="Tbody">
      <tr>
          <td>
             <button class="add_button"
                type="submit"
                hx-post="/add_row/"
                hx-target="#Tbody"
                hx-swap="beforeend"
                >
                  Add A New Row
             </button>
          </td>
      </tr>
  </tbody>
</table>

部分/secondary_hx.html:

<tr hx-target="this"
    hx-swap="outerHTML">
    <td>{{ form.a }}</td>
    <td>{{ form.b }}</td>
    <td>{{ form.c }}</td>
</tr>
4

0 回答 0