0

I would like to search without diacritics in my table. I have DataTables plugin and I want to add dataTable accent neutralise I tried many possibilities, but I dont know still where to exactly place this code or something similar:

<script>
$(document).ready( function () {
jQuery.fn.DataTable.ext.type.search.string = function ( data ) {
return ! data ?
    '' :
    typeof data === 'string' ?
        data
            .replace( /έ/g, 'ε' )
            .replace( /[ύϋΰ]/g, 'υ' )
            .replace( /ό/g, 'ο' )
            .replace( /ώ/g, 'ω' )
            .replace( /ά/g, 'α' )
            .replace( /[ίϊΐ]/g, 'ι' )
            .replace( /ή/g, 'η' )
            .replace( /\n/g, ' ' )
            .replace( /á/g, 'a' )
            .replace( /é/g, 'e' )
            .replace( /í/g, 'i' )
            .replace( /ó/g, 'o' )
            .replace( /ú/g, 'u' )
            .replace( /ê/g, 'e' )
            .replace( /î/g, 'i' )
            .replace( /ô/g, 'o' )
            .replace( /è/g, 'e' )
            .replace( /ï/g, 'i' )
            .replace( /ü/g, 'u' )
            .replace( /ã/g, 'a' )
            .replace( /õ/g, 'o' )
            .replace( /ç/g, 'c' )
            .replace( /ì/g, 'i' ) :
        data;
};
var table = $('#tabulka_kariet').DataTable();

} );
</script>

When I have cleaned code only with dataTable and with this script and table , everything is working fine. Working demo

But in my web this script is not working.

This is my heading:

<head>
<meta charset="UTF-8">
<title>Požičovňa náradia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet"href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="jquery/dataTables.bootstrap.min.css" />
<link rel="stylesheet" type="text/css"    href="https://cdn.datatables.net/1.10.15/css/jquery.dataTables.min.css"></link>
<script src="jquery/accent-neutralise.js"></script> <!-- At this row I tried to load script from website -->

<link rel="stylesheet" href="style.css">
</head>
<body>

And this is my footer:

  </body>
  <!-- Jquery -->
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
  <!-- Datatables -->
  <script src="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"></script>

  <!-- Bootstrap -->
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
  <script>
        $(document).ready(function() {
          $('#tabulka_kariet').DataTable();
   } );
      </script>
  </html>
Prashant Pokhriyal
  • 3,727
  • 4
  • 28
  • 40
David
  • 35
  • 8
  • Exactly where are you facing challenges? I saw working demo and it's working fine – Prashant Pokhriyal Oct 05 '17 at 15:13
  • A working demo is not useful to us... You should cut off most fat from your application but still provide us with a reproduction of your problem. – Salketer Oct 05 '17 at 16:02
  • I'm not sure how to help on this exact matter, but have a look at my latinize function. This will help you optimize your character substitution: https://pastebin.com/Ffan6bQD – Salketer Oct 05 '17 at 16:12
  • Thanks. I changing subpages using php switch. In index.php I have all head and footer. And table is in another file - table.php. In this case searching is not fully function. But when I add to the table.php head and footer, so searching is OK and I can search without diacritics. But result is doubled heads and tags ` – David Oct 09 '17 at 10:51

0 Answers0