Hello @Andrew,
The below code works for me. Note that you need to assign a CSS class to the Title field, e.g. typeahead.
window.$ = $;
window.jQuery = jQuery;
fd.spRendered(function() {
// To avoid conflicts with requireJS which is available by default in SharePoint
// we unset 'define' function until the script are loaded
var define = window.define;
window.define = undefined;
$.getScript('https://cdnjs.cloudflare.com/ajax/libs/corejs-typeahead/1.3.1/typeahead.bundle.min.js')
.then(function() {
window.define = define;
var substringMatcher = function(strs) {
return function findMatches(q, cb) {
var matches, substringRegex;
// an array that will be populated with substring matches
matches = [];
// regex used to determine if a string contains the substring `q`
substrRegex = new RegExp(q, 'i');
// iterate through the pool of strings and for any string that
// contains the substring `q`, add it to the `matches` array
$.each(strs, function(i, str) {
if (substrRegex.test(str)) {
matches.push(str);
}
});
cb(matches);
};
};
var states = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware'];
$('.typeahead input.form-control').typeahead({
hint: true,
highlight: true,
minLength: 1
},
{
name: 'states',
source: substringMatcher(states)
});
});
});