How do you check the jQuery DataTables if a row has been selected? I am trying to have a completed button that submits to the database when pressed only if a row from the DataTable has been selected. If the row has not been selected and the button is pressed I want it to alert the user and tell them they must select a row to complete.
What I have tried:
$(document).ready(function () {
$("#CompleteIt").click(function () {
var table = $('#processing').DataTable();
$('#processing tbody').on( 'click', 'tr', function () {
var rowdata = table.row( this ).data();
console.log(rowdata);
if (!rowdata) {
console.log(rowdata.id);
alert("Please choose a batch to be completed.");
return false;
} else {
}
});