Using Twitter Boostrap TypeAhead along with MVC4 - is there any way I can change the javascript for typeahead, to highlight ANY word in the search box, as opposed to exactly what is in the search box eg. if I type Outlook, it highlights Outlook in the 4 items in the drop down:
However, if I type "outlook access" (which appears in the 4th item above) - it IS returned in the JSON from my controller, however, TypeAhead does not display it as "Outlook access" does not appear as one string in the entries:
I suspect the answer is here (typeahead JS) but not certain:
, highlighter: function (item) {
var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
return '<strong>' + match + '</strong>'
})
}
, render: function (items) {
var that = this
items = $(items).map(function (i, item) {
i = $(that.options.item).attr('data-value', item)
i.find('a').html(that.highlighter(item))
return i[0]
})
items.first().addClass('active')
this.$menu.html(items)
return this
}
Thanks for any help,
Mark