Reputation: 15027
How to setup server side processing and not to load the datatable right away but on a button?
With this setup:
var usersTable = $('#users').DataTable({
responsive: true,
processing: true,
serverSide: true,
autoWidth: false,
ajax: 'https://example.com/users',
..............................
the datatable is loaded straight away and I want to load it on click
Is this possible somehow?
Upvotes: 0
Views: 108
Reputation: 2146
How about:
<button id="my_button" value="click to load DB table!" />
<script>
$( document ).ready(function() {
$('#my_button').click(function(){
load_table();
});
function load_table() {
var usersTable = $('#users').DataTable({
responsive: true,
processing: true,
serverSide: true,
autoWidth: false,
ajax: 'https://example.com/users',
..............................
});
}
});
</script>
Upvotes: 1