1
0
mirror of https://github.com/salexdv/bsl_console.git synced 2024-11-24 08:33:29 +02:00

tree dispose

This commit is contained in:
salexdv 2022-08-25 15:04:10 +03:00
parent 253b75a171
commit 31f5e72b2b

View File

@ -1,17 +1,19 @@
class Treeview {
constructor(treeviewId, editor, imageBase) {
let self = this;
this.treeviewId = treeviewId;
this.editor = editor;
this.selected = null;
this.imageBase = imageBase;
document.querySelector(this.treeviewId).addEventListener("click", (event) => {
this.on("click", event);
});
document.querySelector(this.treeviewId)
this.clickListener = function(event) {
self.on("click", event);
}
document.querySelector(this.treeviewId).addEventListener("click", this.clickListener);
};
on(eventName, eventData) {
switch (eventName) {
switch (eventName) {
case "click": {
console.log(eventData);
if (eventData.target.tagName == 'A') {
eventData.preventDefault();
let element = eventData.target;
@ -106,6 +108,7 @@ class Treeview {
document.getElementById(id).click();
};
dispose() {
document.querySelector(this.treeviewId).removeEventListener("click", this.clickListener);
document.querySelector(this.treeviewId).innerHTML = '';
};
}