javascript - Jquery Autocomplete custom return data -
hello i'm using jquery autocomplete project i've particular problem language. here in albania our alphabet includes characters ë , ç people don't know keyboard combination produce character , i'm trying return these words using 'e' , 'c'. example when people search 'dhermi' want show word 'dhërmi' suggestions. same word "canta" want show "çanta". here many words these want function return data in way.
below function
$("#search").autocomplete({ minlength:0, delay:10, appendto: ".search", source:function(request, response) { // var matchernormal = new regexp( "^" + $.ui.autocomplete.escaperegex( request.term ), "i" ); matcher = $.grep(tagsarr, function( item ){return matchernormal.test(item);}) console.log(matcher) // limit results var results = $.ui.autocomplete.filter(matcher, request.term); response(results.slice(0, 10)); } }); i'll grateful if me problem i've encountered.
what looking accent folding: https://jqueryui.com/autocomplete/#folding
you can have map of accent characters normalised characters
var accentmap = { "á": "a", "ö": "o" }; and function convert 1 other (see example link)
var normalize = function( term ) {....} and compare normalised value of string original one:
return matcher.test( value ) || matcher.test( normalize( value ) );
Comments
Post a Comment