class Menu { constructor() { this.tools = []; $("#tools").empty(); } add(component) { this.tools.push(component); } refresh() { this.tools .filter(component => { return component.created == undefined; }) .forEach(component => { if (component != undefined && component.created) return; component.created = true; const options = component.options; $("#tools").append(``); $("body").on( "click", `#btn-${options.id}`, component.click.bind(component) ); }); } } export const menu = new Menu();