2
0
mirror of https://github.com/frappe/books.git synced 2024-09-21 03:39:02 +00:00
books/client/view/controls/autocomplete.js

25 lines
648 B
JavaScript
Raw Normal View History

2018-03-30 16:56:30 +00:00
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;