autocomplete on empty
This commit is contained in:
@@ -163,6 +163,14 @@ class LinkMultipleFieldView extends BaseFieldView {
|
||||
*/
|
||||
autocompleteMaxCount = null
|
||||
|
||||
/**
|
||||
* Trigger autocomplete on empty input.
|
||||
*
|
||||
* @protected
|
||||
* @type {boolean}
|
||||
*/
|
||||
autocompleteOnEmpty = false
|
||||
|
||||
/**
|
||||
* Select all attributes.
|
||||
*
|
||||
@@ -433,11 +441,13 @@ class LinkMultipleFieldView extends BaseFieldView {
|
||||
setTimeout(() => this.$element.autocomplete('clear'), 300);
|
||||
});
|
||||
|
||||
const minChar = this.autocompleteOnEmpty ? 0 : 1;
|
||||
|
||||
this.$element.autocomplete({
|
||||
serviceUrl: () => {
|
||||
return this.getAutocompleteUrl();
|
||||
},
|
||||
minChars: 1,
|
||||
minChars: minChar,
|
||||
paramName: 'q',
|
||||
noCache: true,
|
||||
autoSelectFirst: true,
|
||||
|
||||
@@ -164,6 +164,14 @@ class LinkFieldView extends BaseFieldView {
|
||||
|
||||
getEmptyAutocompleteResult = null
|
||||
|
||||
/**
|
||||
* Trigger autocomplete on empty input.
|
||||
*
|
||||
* @protected
|
||||
* @type {boolean}
|
||||
*/
|
||||
autocompleteOnEmpty = false
|
||||
|
||||
/** @inheritDoc */
|
||||
events = {
|
||||
/** @this LinkFieldView */
|
||||
@@ -536,7 +544,7 @@ class LinkFieldView extends BaseFieldView {
|
||||
return this.getAutocompleteUrl(q);
|
||||
},
|
||||
lookup: (q, callback) => {
|
||||
if (q.length === 0) {
|
||||
if (!this.autocompleteOnEmpty && q.length === 0) {
|
||||
isEmptyQueryResult = true;
|
||||
|
||||
if (this.getEmptyAutocompleteResult) {
|
||||
|
||||
Reference in New Issue
Block a user