我的Meteor應用程序出現問題。顯然,數據表不能正確更新。當我保存一個新的數據時,它會自動添加一個新行,但表格沒有正確更新(例如,它表示「顯示6條目中的1到6條」,實際上它已經有7條條目了。)流星 - 使數據表無效
我也試圖摧毀表,然後重新初始化它,但沒有運氣。我讀過自動運行功能,但我不確定如何實現它。
有沒有辦法通過JS手動刷新/重新渲染模板?所以,只要我成功地將數據添加到集合中,我就可以刷新它。
這裏是我的代碼:
HTML:
<!-- Teams -->
<div class="col-lg-6">
<div class="ibox float-e-margins">
<div class="ibox-content">
<p><h3>Teams Collection</h3></p>
<div class="hr-line-dashed"></div>
<div class="master-teams-table">
<div class="table-responsive" style="overflow-x:initial !important;">
<table class="table table-striped table-bordered table-hover teamsTable" >
<thead>
<tr>
<th class="text-center">Team Name</th>
<th class="text-center">Abbreviation</th>
<th class="text-center">Tower</th>
</tr>
</thead>
<tbody>
{{#each masterAllTeams}}
<tr>
<td>{{team_name}}</td>
<td>{{team_abbreviation}}</td>
<td>{{tower}}</td>
</tr>
{{/each}}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!-- End of Teams -->
助手:
UI.registerHelper("masterAllTeams", function() {
return TeamsCollection.find();
});
感謝您的幫助!
如果您想顯示條目的數量,例如顯示「x」只是爲它添加一個幫手,你沒有發佈那部分代碼。 –
我正在使用jquery Datatable,所以這部分應該是自動的。它看起來像新添加的行不在數據表本身上註冊。 – user3545006
使用一個類似'aldeed:tabular'的包,它爲你處理大部分內容。 –