in Education by
Please refer to my test case https://jsfiddle.net/1c3Lmace/13/ This is my code $(document).ready(function() { $('#example').DataTable( { dom: 'C<"clear">lfrtip', "fnPreDrawCallback": function( oSettings ) { alert('pre'); }, "fnDrawCallback" : function() { alert('+++++'); } } ); } ); When you go to Show/Hide Columns and click on any column item you will see that each preDrawCallBack and drawCallback event fires twice. Does anyone having any idea why it happens. I want to show a loader before data loads and hide it and when data is successfully loaded. Any help is appreciated Thanks JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Indeed the events are fired twice but only when sorted column visibility is being toggled. I see no point in showing loading indicator for client-side processing, column visibility changes occur very fast. For server-side processing, there is processing option already available. You can do something like this. But I had to put an alert() because columns are toggled very fast and Processing... message disappears quickly. $(document).ready(function() { $('#example').DataTable( { dom: 'C<"clear">lfrtip', processing: true, drawCallback : function() { $('.dataTables_processing', $('#example').DataTable().table().container()).hide(); } } ); } ); $('#example').on( 'column-visibility.dt', function ( e, settings, column, state ) { $('.dataTables_processing', $('#example').DataTable().table().container()).show(); alert('Column visibility is toggled'); } ); See this jsFiddle for code and demonstration.

Related questions

0 votes
    I have the following Javascript code which controls an accordion type set of divs. The set of divs is ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    So now I'm trying to customize Jquery steps by adding a score for each question's option. But the ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    I used the example from here http://jqueryui.com/demos/dialog/#animated to create a dialog box. The ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    In the following code, I am attempting to act upon the li element being hovered over. HTML: foo ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    As it currently stands, this question is not a good fit for our Q&A format. We expect answers to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 23, 2022 in Education by JackTerrance
0 votes
    As it currently stands, this question is not a good fit for our Q&A format. We expect answers to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 23, 2022 in Education by JackTerrance
0 votes
    As it currently stands, this question is not a good fit for our Q&A format. We expect answers to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 23, 2022 in Education by JackTerrance
0 votes
    $(document).ready(function(){ alert("funciton"); $(function(){ $.fn.gotof(){ alert("I am ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 21, 2022 in Education by JackTerrance
0 votes
    $(document).ready(function(){ alert("funciton"); $(function(){ $.fn.gotof(){ alert("I am ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    $(document).ready(function(){ alert("funciton"); $(function(){ $.fn.gotof(){ alert("I am ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    I've a datepicker, using jQuery. But I want to substract 5 days from the date that is selected ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    I've a datepicker, using jQuery. But I want to substract 5 days from the date that is selected ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    I made a form with an imput text and a select. To submit the form i want the user to click a ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    I made a form with an imput text and a select. To submit the form i want the user to click a ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    I have developed a website that queries NASA's image API. The website works fine on my desktop browser. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
...