2014-12-15 8 views
7

Wie kann ich eine Tabelle mit Eingabefeldern in Meteor erstellen. Ich habe das Beispiel von http://autoform.meteor.com/update-each verwendet, aber sie verwenden nur 1 Eingabefeld.Editierbare Tabelle mit AutoForm in Meteor

Die Funktionalität arbeitet mit diesem Code:

<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> 

aber es schuf ein <form> Element um jede <tr> und Schrauben meine html nach oben. Was ist der richtige Weg?

+0

Ein Formular in einer Tabelle ist kein gültiges HTML. Das Formular sollte sich um den Tisch wickeln oder innerhalb eines '' liegen. Mehr hier: http://stackoverflow.com/questions/14576976/where-are-the-form-elements-allowed-within-a-table-element –

+0

Aber '{{# #AutoForm id = makeUniqueID type =" update "Sammlung = Collections.Persons doc = this autosave = true}} 'muss für jede Schleife in meinem sein. Also ich weiß nicht was ich machen soll. – Jamgreen

+1

Sie könnten divs anstelle von Tabelle verwenden und das Tabellenlayout fälschen. http://stackoverflow.com/questions/11049149/how-to-achieve-table-layout-without-using-tables –

Antwort

1

Verwenden div s mit 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> 

und Stil als solche:

.table { 
    display: table; 
} 

.tr { 
    display: table-row; 
} 

.td { 
    display: table-cell 
} 
Verwandte Themen