As you can see below, I have an event listener within the processServiceConsumers function. How can I have it outside the functions so it’s a global event listener?
function getServiceConsumers() {
return $.ajax({
url: baseURL + "serviceConsumers?connectionPointId=" + ntjpProdConnectionPointId,
success: function(result){
processServiceConsumers(result);
}
});
}
function processServiceConsumers(data) {
$("#serviceConsumersWrapper").show();
var serviceConsumersTable = $('#serviceConsumersTable').DataTable( {
data: data,
dataSrc: "",
columns: [
{ data: "id", orderData: 2 },
{ data: "hsaId" },
{ data: "description" }
],
select: true
} );
serviceConsumersTable.on( 'select', function () {
var selectedRowId = serviceConsumersTable.rows( { selected: true } ).data()[0].id;
// getServiceContracts(selectedRowId);
} );
}