forked from public/foundryvtt-reve-de-dragon
Fix multi-dialogs
Arrêter d'utiliser le jQuery $(selector) qui cause des effets de bord si plusieurs élements de la page (ie: foundry) correspondent au selector. Stocker le html dans les Sheet/Dialogs lors de l'appel activateListeners afin de pouvoir s'y référer ensuite. Utiliser this.html.find pour chercher dans le html de la fenêtre courante. Eliminer les référence par id html car l'id est unique (donc ne marche pas en multi-fenêtres)
This commit is contained in:
@ -17,7 +17,7 @@ export class DialogConsommer extends Dialog {
|
||||
buttons: {
|
||||
[consommerData.buttonName]: {
|
||||
label: consommerData.buttonName, callback: async it => {
|
||||
await this.onConsommer(it);
|
||||
await this.onConsommer();
|
||||
await onActionItem();
|
||||
}
|
||||
}
|
||||
@ -31,9 +31,16 @@ export class DialogConsommer extends Dialog {
|
||||
this.consommerData = consommerData;
|
||||
}
|
||||
|
||||
async onConsommer(event) {
|
||||
await $(".se-forcer").change();
|
||||
await $(".consommer-doses").change();
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
this.html = html;
|
||||
this.html.find(".se-forcer").change(event => this.setSeForcer(event));
|
||||
this.html.find(".consommer-doses").change(event => this.selectDoses(event));
|
||||
}
|
||||
|
||||
async onConsommer() {
|
||||
await this.html.find(".se-forcer").change();
|
||||
await this.html.find(".consommer-doses").change();
|
||||
await this.actor.consommer(this.item, this.consommerData.choix);
|
||||
}
|
||||
|
||||
@ -92,14 +99,6 @@ export class DialogConsommer extends Dialog {
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
html.find(".se-forcer").change(event => this.setSeForcer(event));
|
||||
html.find(".consommer-doses").change(event => this.selectDoses(event));
|
||||
}
|
||||
|
||||
|
||||
setSeForcer(event) {
|
||||
this.consommerData.choix.seForcer = event.currentTarget.checked;
|
||||
}
|
||||
@ -107,7 +106,7 @@ export class DialogConsommer extends Dialog {
|
||||
selectDoses(event) {
|
||||
this.consommerData.choix.doses = Number(event.currentTarget.value);
|
||||
DialogConsommer.calculDoses(this.consommerData, this.item);
|
||||
$(".total-sust").text(this.consommerData.totalSust);
|
||||
$(".total-desaltere").text(this.consommerData.totalDesaltere);
|
||||
this.html.find(".total-sust").text(this.consommerData.totalSust);
|
||||
this.html.find(".total-desaltere").text(this.consommerData.totalDesaltere);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user