const select = new Select(
document.querySelector('.select'),
'Selected items',
'../select.json'
);
const select = new Select({
selector: '.select',
label: 'Selected items',
url: '../select.json',
onOpen() {
console.log('open')
},
onClose(){
console.log('close')
}
});
class Select {
constructor({
selector,
label,
url,
onOpen,
onClose
}) {
this.container = document.querySelector(selector);
this.label = label;
this.url = url;
this._onOpen = onOpen;
this._onClose = onClose;
...
}
...
open() {
...
if (this._onOpen !== undefined) {
this._onOpen();
}
}
close() {
...
if (this._onClose !== undefined) {
this._onClose();
}
}
}