vue-modal
vue-modal copied to clipboard
promptModal
Main goal: to add the ability to connect to linear modal windows. A linear modal window is a window whose main task is to return a value. Referencing promt in JavaScript. Tasks:
- implementation of the promtModal method (Or another name, while being discussed)
- value return implementation
Principle of operation:
const result = promptModal(VueModal);
// VueModal.vue
<template>
<div>
<button @click = "change(1)">up</button>
<button @click = "change(-1)">down</button>
</div>
</template>
<script setup>
function change(v) {
emit('close', v);
}
</script>
This example demonstrates a modal window that will return either 1 or -1 (undefined if it was closed with Esc or background)
The only thing that worries is that we are removing the close event from use. It is possible to add the returnValue(value) method to solve this problem. The change function will look like this:
import {returnValue} from "jenesius-vue-modal"
function change(v) {
returnValue(v);
}
Also need add prop returnValue to EventClose, or just value
The main problem is how returnValue caught where it was called from...
Jenesius is back I test the solution in my work project. On this week will be news: New method: promptModal Form.EVENT_PROMPT