mirror of
https://github.com/frappe/books.git
synced 2024-12-23 03:19:01 +00:00
validate function for autocomplete
This commit is contained in:
parent
7eeb3ca137
commit
a74ec62abe
@ -8,18 +8,26 @@ class AutocompleteControl extends BaseControl {
|
||||
this.setupAwesomplete();
|
||||
}
|
||||
|
||||
setupAwesomplete() {
|
||||
async setupAwesomplete() {
|
||||
this.awesomplete = new Awesomplete(this.input, {
|
||||
minChars: 0,
|
||||
maxItems: 99
|
||||
});
|
||||
|
||||
this.list = await this.getList();
|
||||
|
||||
// rebuild the list on input
|
||||
this.input.addEventListener('input', async (event) => {
|
||||
let list = await this.getList();
|
||||
this.awesomplete.list = list;
|
||||
this.input.addEventListener('input', (event) => {
|
||||
this.awesomplete.list = this.list;
|
||||
});
|
||||
}
|
||||
|
||||
validate(value) {
|
||||
if (this.list.includes(value)) {
|
||||
return value;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = AutocompleteControl;
|
Loading…
Reference in New Issue
Block a user