Commit 4a1f5f06 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Merge branch 'F10145typeaheadMinLength0' into 'develop'

experimentation

See merge request !370
parents 80608319 242f168e
Pipeline #6520 passed with stages
in 3 minutes and 2 seconds
......@@ -44,6 +44,11 @@ var QfqNS = QfqNS || {};
}
};
var url = n.TypeAhead.makeUrl(typeahead_endpoint, $element);
url = url.replace('%QUERY', '');
console.log(url);
$.getJSON(url, {}, console.log); // API by hand
// initialize typeahead (either with or without tags)
if ($element.data('typeahead-tags')) {
n.TypeAhead.installWithTags($element, bloodhoundConfiguration);
......@@ -152,6 +157,19 @@ var QfqNS = QfqNS || {};
});
tagApi.tagsManager('disableHiddenUpdate', false);
console.log(JSON.parse(JSON.stringify(n.TypeAhead.getMinLength($element))));
function suggestionsWithDefaults(q, sync, async) {
if (q === '') {
sync(suggestions.index.all().slice(0, 2)); // slice(start,end)
// suggestions.search('', sync, async);
}
else {
suggestions.search(q, sync, async);
}
}
$inputField.data('bloodhound', suggestions);
// add typahead
$inputField.typeahead({
// options
......@@ -160,7 +178,7 @@ var QfqNS = QfqNS || {};
minLength: n.TypeAhead.getMinLength($element)
}, {
display: 'value',
source: suggestions,
source: suggestionsWithDefaults,
limit: n.TypeAhead.getLimit($element),
templates: {
suggestion: function (obj) {
......@@ -213,7 +231,6 @@ var QfqNS = QfqNS || {};
};
})($element, suggestions));
$element.typeahead({
// options
hint: n.TypeAhead.getHint($element),
......@@ -322,7 +339,7 @@ var QfqNS = QfqNS || {};
};
n.TypeAhead.getMinLength = function ($element) {
return $element.data('typeahead-minlength') || 2;
return $element.data('typeahead-minlength') !== undefined ? $element.data('typeahead-minlength') : 2;
};
n.TypeAhead.getHighlight = function ($element) {
......
......@@ -144,9 +144,10 @@
<input id="tags1" type="hidden" class="form-control qfq-typeahead" name="tags1"
data-typeahead-sip="abcdef"
data-typeahead-limit="10"
data-typeahead-minlength="1"
data-typeahead-minlength="0"
data-typeahead-tags="true"
data-typeahead-pedantic="0"
data-typeahead-tag-delimiters="[9, 13]"
value="<?php echo $tagsSafeJson; ?>"
>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment