javascript - JQuery Autocomplete search both to letters -


i implemented autocomplete fetch data ajax post database , add them autocomplete item. shown below

jquery.ajax({       url: "--url--",       datatype: 'jsonp',       success: function(data){          jquery("#location_finder").autocomplete({              source: function( request, response ) {                  var lookup = jquery.ui.autocomplete.escaperegex( request.term );                  var matcher = new regexp( "^" + lookup, "i" );                  response( jquery.grep(data, function(item){                       return matcher.test(item);                  }));              }          });      },  });

the data after post come :

data = ['berti','simon','Çarli','cherpa'];

while doing typing in input field letter "c" "cherpa" shown try show "Çarli" user. how can handle , give option user both letter "c" , "Ç"? in advance.

you can try :

var lookup = jquery.ui.autocomplete.escaperegex( request.term ); if(lookup.indexof('c') != -1 || lookup.indexof('Ç') != -1) {     lookup.replace("c", "(c|Ç)");     lookup.replace("Ç", "(c|Ç)") } var matcher = new regexp( "^" + lookup, "i" ); 

Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -