入力フィールドを持つ DataTables.net のテーブルがあります。
<table id="example" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr class="text-center">
<th scope="col">Name</th>
<th scope="col">Level</th>
<th scope="col">Save</th>
</tr>
</thead>
<tbody>
{% for member in form.users %}
<tr>
<td>{{ member.username(class="form-control form-control-lg") }}</td>
<td>{{ member.user_level(class="form-control form-control-lg") }}</td>
<td><button type="button" user_id="{{member.id}}" class="btn btn-primary btn-save-user">Save</button></td>
</tr>
{% endfor %}
</tbody>
</table>
だから私は値を編集し、行のボタンを押して行を保存したいSave:
$(document).on('click', '.btn-save-user', function (e) {
var row = dataTable.row( dataTable.row( $(this).parents('tr') ).index( ));
console.log(row.node().$('input, select').serialize());
});
しかし、エラーが発生します:
row.node(...).$ is not a function
私が行った場合:
console.log(row.nodes().$('input, select').serialize());
すべての行の値を取得します。
1行の入力から値を取得する方法は?