I'm using jQuery DataTables.
This is my markup:
<div class='wrapper'>
<form>
<table>
<tr>
<td><input type='checkbox' value='1' /></td>
<td>Some Data</td>
</tr>
</table>
</form>
</div>
<button>delete</button>
I have multiple rows and each has a checkbox. Normally, I would do this to grab all inputs inside the form:
var data = $('form input').serialize();
But, since I'm using DataTables, it says here I should use this instead:
var oTable = $('table').dataTable();
var data = $('input', oTable.fnGetNodes()).serialize();
Unfortunately, console.log(data) here returns (empty string). I've been reading up on documentation but, so far, nothing has helped.
I tried logging oTable.fnGetNodes() and it returns the tr's of the table. I'm at a loss here. Any help is appreciated.
<td><input type='checkbox' value='1' /></td>
You need the name attribute for serialize to work here. Otherwise, it doesn't see any valid form elements inside the form.
<td><input type='checkbox' value='1' name='check[]' /></td>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With