バックボーンを使用してunderscorejsによってレンダリングされたテンプレートでデータテーブルを使用しようとしています。私のテンプレートコードはこれです:
<script type="text/template" id="ledgerListing">
<table>
<thead>
<tr><th>Name</th><th>Email</th><th>Phone</th><th>address</th></tr>
</thead>
<tbody>
<tr><td>mrinal</td><td>mrinal</td><td>mrinal</td><td>mrinal</td></tr>
</tbody></table>
</script>
そして、私の見解の1つでは、次のような機能を実行します。
ledgerTemplate: _.template($("#ledgerListing").html()),
loadLedger: function(){
this.container.html(this.ledgerTemplate());
}
ページの上部で、次のようにデータテーブルを初期化します。
$(document).ready(function() {
$('table').dataTable();
} );
テーブルはレンダリングされますが、datatableプラグインは適用されません。スクリプトタグ内のものは、ページの読み込み中にDOMに接続されていないと思います。この場合、underscorejsによってレンダリングされたテンプレートにデータテーブルを適用する方法は何ですか。助言がありますか...