diff --git a/module/system/applications.mjs b/module/system/applications.mjs index 6c95b98..2714f1d 100644 --- a/module/system/applications.mjs +++ b/module/system/applications.mjs @@ -1,3 +1,5 @@ +const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api + export class TotemPicker extends HandlebarsApplicationMixin(ApplicationV2) { constructor(linkEl, actor) { @@ -24,9 +26,9 @@ export class TotemPicker extends HandlebarsApplicationMixin(ApplicationV2) { return { config: CONFIG.VERMINE }; } - activateListeners(html) { - super.activateListeners(html); - html.querySelectorAll('.totem').forEach(el => { + _onRender(context, options) { + super._onRender(context, options); + this.element.querySelectorAll('.totem').forEach(el => { el.addEventListener('click', event => { const link = event.target.closest('a'); if (!link?.dataset.totem) return; @@ -80,9 +82,9 @@ export class ActorPicker extends HandlebarsApplicationMixin(ApplicationV2) { }; } - activateListeners(html) { - super.activateListeners(html); - html.querySelectorAll('.actor').forEach(el => { + _onRender(context, options) { + super._onRender(context, options); + this.element.querySelectorAll('.actor').forEach(el => { el.addEventListener('click', async event => { const div = event.target.closest('div'); const actorId = div?.dataset.actorId; @@ -148,15 +150,15 @@ export class TraitSelector extends HandlebarsApplicationMixin(ApplicationV2) { }; } - activateListeners(html) { - super.activateListeners(html); - this._validateTraits(html); - html.querySelectorAll('input').forEach(el => { + _onRender(context, options) { + super._onRender(context, options); + this._validateTraits(this.element); + this.element.querySelectorAll('input').forEach(el => { el.addEventListener('change', ev => this._onChangeInput(ev)); }); } - async _validateTraits(html) { + _validateTraits(html) { const checks = html.querySelectorAll("input.trait-selector"); for (const inp of checks) { if (this.targetItem.system.traits[inp.dataset.trait]) { @@ -165,7 +167,6 @@ export class TraitSelector extends HandlebarsApplicationMixin(ApplicationV2) { } } } - await this.render(true); } async _onChangeInput(ev) { diff --git a/module/system/fight.mjs b/module/system/fight.mjs index 1419bf9..a2d11d6 100644 --- a/module/system/fight.mjs +++ b/module/system/fight.mjs @@ -239,9 +239,9 @@ export class VermineCombatTracker extends foundry.applications.sidebar.tabs.Comb return context; } - activateListeners(html) { - super.activateListeners(html); - html.querySelectorAll("[data-attitude]").forEach(el => { + _onRender(context, options) { + super._onRender(context, options); + this.element.querySelectorAll("[data-attitude]").forEach(el => { el.addEventListener("click", this._setStatut.bind(this)); }); }