mirror of
https://github.com/frappe/books.git
synced 2024-12-25 12:10:06 +00:00
25 lines
648 B
JavaScript
25 lines
648 B
JavaScript
const BaseControl = require('./base');
|
|
const Awesomplete = require('awesomplete');
|
|
|
|
class AutocompleteControl extends BaseControl {
|
|
make() {
|
|
super.make();
|
|
this.input.setAttribute('type', 'text');
|
|
this.setupAwesomplete();
|
|
}
|
|
|
|
setupAwesomplete() {
|
|
this.awesomplete = new Awesomplete(this.input, {
|
|
minChars: 0,
|
|
maxItems: 99
|
|
});
|
|
|
|
// rebuild the list on input
|
|
this.input.addEventListener('input', async (event) => {
|
|
let list = await this.getList();
|
|
this.awesomplete.list = list;
|
|
});
|
|
}
|
|
};
|
|
|
|
module.exports = AutocompleteControl; |