Answer the question
In order to leave comments, you need to log in
How to create a plugin?
Hello
Created my first plugin (bike) - code
Now like this
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')
}
});
Answer the question
In order to leave comments, you need to log in
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();
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question