Avoid .on( 'draw.dt', initMap ); in Datatable
Avoid .on( 'draw.dt', initMap ); in Datatable
Mausino
Posts: 61Questions: 19Answers: 0
Link to test case:
Hi, i want initialize .on( 'draw.dt', initMap ); only for core search function in DataTables but not for hideMarkers() function. It is possible somehow avoid it or detect if core search was used in DataTable?
$(document).ready(function () {
var table = $('#example').DataTable().on( 'draw.dt', initMap );
function hideMarkers(marker) {
$.fn.dataTable.ext.search.push(function (settings, data, dataIndex) {
if (marker === 'visible') {
return true;
}
return false;
});
// here i want somehow avoid initMap in example DataTable but don't know
$('#example').DataTable().draw();
}
});
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
This question has an accepted answers - jump to answer
Answers
You'd need to set a flag in your
hideMarkers
function. One which yourinitMap
function can also access. Then ininitMap
check if the flag is set or not to determine ifhideMarkers
triggered the draw.Allan