2
0
mirror of https://github.com/frappe/books.git synced 2024-12-25 12:10:06 +00:00
books/client/view/controls/autocomplete.js
2018-03-30 22:27:13 +05:30

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;