gpt4 book ai didi

twitter-bootstrap - 将 Bootstrap Typeahead 匹配器设置为不区分大小写

转载 作者:行者123 更新时间:2023-12-04 14:48:25 25 4
gpt4 key购买 nike

我需要将 Twitter Bootstrap Typeahead 插件中的匹配器设置为不区分大小写。 Bootstrap 文档指定需要将一个函数传递给 typeahead 选项,但没有指定该函数应该是什么。

如果有人能告诉我如何做到这一点,我将不胜感激。

提前致谢 :)

最佳答案

matchertypeahead 的参数中的一个选项功能。从文档中:

The method used to determine if a query matches an item. Accepts a single argument, the item against which to test the query. Access the current query with this.query. Return a boolean true if query is a match.



所以,它看起来像这样:
$('.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
}
})

它还在文档中说此回调的默认行为是 case insensitive匹配器。因此,您的需求应该开箱即用。

关于twitter-bootstrap - 将 Bootstrap Typeahead 匹配器设置为不区分大小写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10815959/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com