Triggering dialog / modal via javascript #601
-
Is there a way to trigger a dialog via javascript? I can't find it anywhere in the docs or by searching how to do that with radix vue |
Beta Was this translation helpful? Give feedback.
Answered by
sadeghbarati
Jun 11, 2024
Replies: 2 comments 1 reply
-
You can use controlled components and control it with ref and |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
lea0o0oo
-
For anyone wondering, it will be something like this <script setup>
import { ref, onMounted } from "vue";
let showModal = ref(false);
showModal.value = true // Show modal
showModal.value = false // Hide modal
function openWithClickOnButtonForExample() {
showModal.value = true
}
onMounted(() => {
showModal.value = true
})
</script>
<template>
<button @click="openWithClickOnButtonForExample">click</button>
<Dialog v-model:open="showModal">
<DialogContent>
<DialogHeader>
<DialogTitle>Hi</DialogTitle>
</DialogHeader>
</DialogContent>
</Dialog>
</template> |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use controlled components and control it with ref and
v-model:open
onDialog
component