Modernise the typeahead stuff to squash some bugs.

This commit is contained in:
James Cole
2018-09-17 17:41:34 +02:00
parent f76fdedd25
commit 744d45fb04
19 changed files with 228 additions and 148 deletions

View File

@@ -362,13 +362,21 @@ function updateTriggerInput(selectList) {
function createAutoComplete(input, URI) {
console.log('Now in createAutoComplete().')
input.typeahead('destroy');
$.getJSON(URI).done(function (data) {
console.log('Input now has auto complete from URI ' + URI);
input.typeahead({source: data, autoSelect: false});
}).fail(function () {
console.log('Could not grab URI ' + URI + ' so autocomplete will not work');
});
var source = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: {
url: URI,
filter: function (list) {
return $.map(list, function (name) {
return {name: name};
});
}
}
});
source.initialize();
input.typeahead({}, {source: source, displayKey: 'name', autoSelect: false});
}
function testRuleTriggers() {