Hello, I wanted to know how I can be using typeahead
on various inputs.
row
with some inputs, in the first input I am using typeahead
to search words, it is possible to clone this row
thus making new entries.
The problem is, typeahead
only works on the first input, otherwise it does not work.
<input type="text" name="palavras" class="form-control typeahead" data-provide="typeahead">
var substringMatcher = function (strs) {
return function findMatches(q, cb) {
var matches, substrRegex;
matches = [];
substrRegex = new RegExp(q, 'i');
$.each(strs, function (i, str) {
if (substrRegex.test(str)) {
matches.push(str);
}
});
cb(matches);
};
};
var palavras= ['olá', 'tudo bem', 'sol', 'praia','neve'];
$('.typeahead').typeahead({
hint: true,
highlight: true,
minLength: 1
},{
name: 'palavras',
source: substringMatcher(palavras)
});
I hope to open a legal discussion on this topic.