How to close programmatically opened nuxt ui modal from within the modal
I have a modal that opens like this:
modal.open(SomeModal, {onClose() => {console.log('closed')})
When clicking outside the modal, it console logs properly, however, when I call modal.close() from inside the modal it does not.
What's the proper way to close the modal from inside? (a cancel button for example)2 Replies
For only closing, you can use
useModal().close()
also from within the modal.
Like this:
If you want your parent component to do something you have to emit a custom event (see the example at https://ui.nuxt.com/components/modal#control-programmatically)Thank you. Used a custom callback to solve this 👍