Match Bootstrap Typeahead to case insensitive

I need to match the Twitter Bootstrap plugin for case insensitive. Bootstrap docs indicate that the function should be passed to typeahead parameters, but does not indicate what the function should be.

I would be grateful if someone would tell me how to do this.

Thanks in advance:)

+6
source share
1 answer

matcher is an option in the parameter for the typeahead function. From the documentation:

The method used to determine if a query matches an element. It takes a single argument, an element with which to check the request. Access the current query with this.query. Returns boolean true if the request is a match.

So it looks something like this:

 $('.typeahead').typeahead({ matcher: function(item) { // Here, the item variable is the item to check for matching. // Use this.query to get the current query. // return true to signify that the item was matched. return true } }) 

The documentation also says that the default behavior for this callback is case insensitive . So, your need should be solved out of the box.

+7
source

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


All Articles