How can I combine javascript(s) in web page?

62 views Asked by At

I have a website with the following:

 ...

 <script src="//cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js"></script>
 <script src="//cdn.datatables.net/responsive/1.0.6/js/dataTables.responsive.js"></script>

I need to combine these scripts into one:

 <script>$(document).ready(function() {$('#cccr').DataTable( { "order": [[ 0, "desc" ], [2,"asc"], [1,"asc"]], "aaSorting": [], "bPaginate": false, "bLengthChange": true, "bFilter": true, "bSort": true, "bInfo": true, "sPaginationType": "full_numbers", "sScrollY": "25rem",  "bStateSave": false, "autoWidth": true });} );</script>

 <script>$(document).ready(function() {var oTable = $('#cccr').dataTable();oTable.fnFilter( 'parry' );} );</script>

 <script>$(document).ready(function() {new $.fn.dataTable.Responsive( table );} );</script>

Problem is that I want the page to be responsive and having the responsive js invocation code separate screws everything up. How can I safely combine these lines? (Preferably w/o "$(document).ready".

1

There are 1 answers

0
nolawi On BEST ANSWER

like this

<script>   
$(document).ready(function() {
  $('#cccr').DataTable({
    "order": [
        [0, "desc"],
        [2, "asc"],
        [1, "asc"]
    ],
    "aaSorting": [],
    "bPaginate": false,
    "bLengthChange": true,
    "bFilter": true,
    "bSort": true,
    "bInfo": true,
    "sPaginationType": "full_numbers",
    "sScrollY": "25rem",
    "bStateSave": false,
    "autoWidth": true
});
 var oTable = $('#cccr').dataTable();
            oTable.fnFilter('parry');
  new $.fn.dataTable.Responsive(table);
 });
 </script>