fix modal
This commit is contained in:
@@ -20,16 +20,16 @@ import { onMounted, onBeforeUnmount, ref, watch } from 'vue'
|
||||
|
||||
export default {
|
||||
props: ['modelValue', 'title', 'class_other'],
|
||||
emits: ['change','update:modelValue'],
|
||||
emits: ['change','update:modelValue','hide'],
|
||||
setup(props, { emit }) {
|
||||
const id = 'modal' + Math.round(Math.random() * 100000)
|
||||
const modal = ref(null)
|
||||
|
||||
const triggerModal = (value, emitEvent = true) => {
|
||||
if (value == true) {
|
||||
modal.modelValue.show()
|
||||
modal.value.show()
|
||||
} else {
|
||||
modal.modelValue.hide()
|
||||
modal.value.hide()
|
||||
if (emitEvent) {
|
||||
emit('hide')
|
||||
}
|
||||
@@ -39,7 +39,7 @@ export default {
|
||||
|
||||
onMounted(() => {
|
||||
document.body.append(document.getElementById(id))
|
||||
modal.modelValue = new Modal(document.getElementById(id))
|
||||
modal.value = new Modal(document.getElementById(id))
|
||||
document.getElementById(id).addEventListener('hidden.bs.modal', function () {
|
||||
triggerModal(false)
|
||||
})
|
||||
@@ -47,7 +47,7 @@ export default {
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
modal.modelValue.hide()
|
||||
modal.value.hide()
|
||||
setTimeout(function () {
|
||||
document.getElementById(id).remove()
|
||||
}, 500)
|
||||
|
||||
Reference in New Issue
Block a user