how to setup accent-neutralization plugin from cdn?

how to setup accent-neutralization plugin from cdn?

Leo BrunoLeo Bruno Posts: 19Questions: 3Answers: 0

I have this datatables:

setupPlugin() {
    this.$el = $(this.el);    
    this.$el.DataTable({               
        "dom": '<"d-flex justify-content-between"fi<"pull-right"l>>t<"d-flex justify-content-between"p<"pull-right"Br>>', 
        "buttons": ["copy", "excel", "pdf", "print", "colvis"],            
        "language": languageStrings,
        "responsive": true,
        "order": [[ 1, "asc" ]],
        "columnDefs": this.getRowButtonsDefs()                        
    }); 
}

how do I set up the accent-neutralization plugin from cdn in this scenario?

Replies

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    You just need to include the JS file for accent-neutralise, as it just adds a new search type,

    Colin

  • Leo BrunoLeo Bruno Posts: 19Questions: 3Answers: 0

    I don´t need to call it on the initialization depcited above?

  • Leo BrunoLeo Bruno Posts: 19Questions: 3Answers: 0

    I don´t know if I´m doing right, but the code bellow doesn´t work:

    setupPlugin() {
        this.$el = $(this.el);    
        accentNeutralize(this.$el.DataTable({               
            "dom": '<"row col-12"<"d-flex justify-content-start col-sm-12 col-md-4"f><"d-flex justify-content-center col-sm-12 col-md-4"i><"d-flex justify-content-end col-sm-12 col-md-4"l>>t<"row col-12"<"d-flex justify-content-start col-sm-12 col-md-6"p><"d-flex justify-content-end col-sm-12 col-md-6"Br>>', 
            "buttons": ["copy", "excel", "pdf", "print", "colvis"],            
            "language": languageStrings,
            "responsive": true,
            "order": [[ 1, "asc" ]],
            "columnDefs": this.getRowButtonsDefs()                        
        })); 
    }
    

    where is the "accentNeutralize" method implementatin, extracted from the cdn link:

    export function accentNeutralize(){

    function removeAccents ( data ) {
        if ( data.normalize ) {
            return data +' '+ data
                .normalize('NFD')
                .replace(/[\u0300-\u036f]/g, '');
        }
    
        return data;
    }
    
    var searchType = $.fn.DataTable.ext.type.search;
    
    searchType.string = function ( data ) {
        return ! data ?
            '' :
            typeof data === 'string' ?
                removeAccents( data ) :
                data;
    };
    
    searchType.html = function ( data ) {
        return ! data ?
            '' :
            typeof data === 'string' ?
                removeAccents( data.replace( /<.*?>/g, '' ) ) :
                data;
    };
    

    };

  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974

    The plugin is applied automatically. You don't need to do anything with your Datatables initialization code. This is a generic environment but I loaded the plugin via CDN and updated Tiger Nixon to be in Zürich. In the Search input type zurich to see the plugin working:
    http://live.datatables.net/wakutona/1/edit

    You can load it via CDN, local file or directly in your JS environment.

    Kevin

Sign In or Register to comment.