繁体   English   中英

在Meteor中使用AutoForm的可编辑表格

[英]Editable table with AutoForm in Meteor

如何在Meteor中创建包含输入字段的表格。 我使用了http://autoform.meteor.com/update-each中的示例,但它们只使用了1个输入字段。

该功能适用​​于此代码:

  <tbody>
    {{#each persons}}
      {{#autoForm id=makeUniqueID type="update" collection=Collections.Persons doc=this autosave=true}}
      <tr>
        <td>{{> afFieldInput name="fullName" label=false}}</td>
        <td>{{> afFieldInput name="email" label=false}}</td>
        <td>{{> afFieldInput name="address" label=false}}</td>
        <td><button type="submit" class="btn btn-xs btn-danger">Delete</button></td>
      </tr>
      {{/autoForm}}
    {{/each}}
  </tbody>

但它在每个<tr>周围创建了一个<form>元素,它搞砸了我的HTML。 这样做的正确方法是什么?

使用div s的CSS:

<div class="table">
  {{#each persons}}
    {{autoform class="tr"}}
      <div class="td">{{> afQuickField}}</div>
      <div class="td">{{> afQuickField}}</div>
      <div class="td">{{> afQuickField}}</div>
    {{/autoform}}
  {{/each}}
</div>

并将其样式设置为:

.table {
  display: table;
}

.tr {
  display: table-row;
}

.td {
  display: table-cell
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM