Level 50
what are you trying to do exactly ? i mean i can't understand your problem.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I created a Confirmation Dialogue modal, when I go to call the modal the Promises from undefined and it executes the entire piece of code I would like that x piece of code to be executed only when I answered in the modal
I created the following modal:
<template>
<t-modal @before-open="onBeforeOpen" :name="modalName" :header="title example"
@closed="onClosed" :click-to-close="false">
<div class="col-span-1 md:col-span-2 text-center text-lg"
v-html="pippo"/>
<div class="flex justify-end mb-2 md:col-span-2">
<t-button class="px-8" variant="primary" @click="submit">
<span class="text-lg"></span> {{ example }}
</t-button>
</div>
</t-modal>
</template>
<script>
import {modal} from "../modal";
export default {
name: "ConfirmChanges",
components: {},
mixins: [modal],
data() {
return {
generating: [],
checked: false,
submitting: false,
modalName: 'confirm-changes',
resolvePromise: undefined,
}
},
methods: {
onBeforeOpen() {
return new Promise((resolve) => {
console.log(resolve)
this.resolvePromise = resolve
})
console.log(this.resolvePromise)
},
submit() {
this.resolvePromise(true)
console.log('submit',this.resolvePromise)
this.$modal.hide(this.modalName)
},
onClosed() {
this.resolvePromise(false)
this.$modal.hide(this.modalName)
},
}
}
</script>
<style scoped>
</style>
then i call the modal inside this method inside a component.
async switchEdit() {
const check = await this.$modal.show('confirm-changes')
if(check){
//I would like this piece of code to be executed only when the Promises
//resolves to true.
//unfortunately it executes me all the method as soon as the modal is opened
}
},
Please or to participate in this conversation.