Does bootstrap typeahead make capital insensitivity?

I use this parameter to do my boot type search in case insensitive mode.

matcher: function(item) { return true } 

I work for accents, for example, by entering "e" the search also รฉ, รจ, รซ, รช, etc. But it does not work for upper lower case => typing "g", does not look for "G" ...

Is there any other option?

+4
source share
2 answers

Ok, here's what I did using the Paul solution:

  matcher: function(item) { if (item.toLowerCase().indexOf(this.query.trim().toLowerCase()) != -1) { return true; } if (item.toUpperCase().indexOf(this.query.trim().toUpperCase()) != -1) { return true; } var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&'); query = query.replace(/a/ig, '[a\341\301\340\300\342\302\344\304]'); query = query.replace(/e/ig, '[e\351\311\350\310\352\312\353\313]'); query = query.replace(/i/ig, '[i\355\315\354\314\356\316\357\317]'); query = query.replace(/o/ig, '[o\363\323\362\322\364\324\366\326]'); query = query.replace(/u/ig, '[u\372\332\371\331\373\333\374\334]'); query = query.replace(/c/ig, '[c\347\307]'); if(item.toLowerCase().match(query.toLowerCase())){ return true; } } 

In doing so, you have a real insensitive case. I put the main special characters. You can add additional characters for the match.

+2
source

Hi, I had the same problem and solved this problem as follows:

     matcher: function (item) {
                 if (item.toLowerCase (). indexOf (this.query.trim (). toLowerCase ())! = -1) {
                     return true;
                 }
             }
0
source

Source: https://habr.com/ru/post/1491892/


All Articles