Vue-js-modal: Dynamic Modal - Close params

Created on 5 Nov 2018  ยท  10Comments  ยท  Source: euvl/vue-js-modal

Problem:

I want to ask how can I send data from the modal to the parent. For example in my modal I am doing an operation and I want to send on close an param: { success: true }. I need to make an difference between when that modal is dismiss or when it is close with the close event.
...

Example & screenshots:

...

I have checked stackoverflow for solutions and 100% sure that issue not in my code.

Most helpful comment

you can use before-close, closed events
This doesn't work for dynamic modals because in this case the event.params is undefined.

All 10 comments

The only way is to use an busEvent between parent and child?

you can use before-close, closed events or as you rightly said - global event bus

also shared state, like vuex could do the job

I just look inside beforeClose and Close and I do something like
this.$emit('close', param ). That param is not pass into the before close or closed event.

The idea is that I want to make a difference between when I close the modal with button close, with button cancel or with clicking outside the modal. It will be a good feature to have a dismiss event on the modal.

Same issue here.

There is no way to pass data ? Or use the fourth argument to catch modal events ?

v.prototype.$modal.open = function(modal, paramsOrProps, params, events = {}) {
    return new Promise((resolve, reject) => {
        Vue.prototype.$modal.show(modal, paramsOrProps, params, { ...events,
            'before-close': (event, data) => {
                events['before-close'] && events['before-close']();

                // Data is always undefined, nor sent in event object
                resolve({ event, data })
            },

            // Or no way to use events emitted by the modal ?
            'custom-modal-event': (evt) => resolve(evt)
        });
    });
}

Same issue here. I have made an Angular implementation of modals, and this feature was a must have. You need to be able to pass data or params with the close events so that the close handlers can differentiate between the modal being dismissed/cancelled or closed/resolved with a value/success result.

The event seemingly already contains a canceled property, but this is always false:

image

2018๋…„ 11์›” 13์ผ (ํ™”) ์˜ค์ „ 10:28, Adam Reis notifications@github.com๋‹˜์ด ์ž‘์„ฑ:

Same issue here. I have made an Angular implementation of modals, and this
feature was a must have. You need to be able to pass data or params with
the close events so that the close handlers can differentiate between the
modal being dismissed/cancelled or closed/resolved with a value/success
result.

The event seemingly already contains a canceled property, but this is
always false:

โ€”
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/euvl/vue-js-modal/issues/353#issuecomment-438071154,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABdxrrT3ijFlxjTXi7OjgJJNoTSumyZlks5uugZygaJpZM4YOyeI
.

2018๋…„ 11์›” 13์ผ (ํ™”) ์˜คํ›„ 3:51, DY Kim dochoul@gmail.com๋‹˜์ด ์ž‘์„ฑ:

>
>

2018๋…„ 11์›” 13์ผ (ํ™”) ์˜ค์ „ 10:28, Adam Reis notifications@github.com๋‹˜์ด ์ž‘์„ฑ:

Same issue here. I have made an Angular implementation of modals, and
this feature was a must have. You need to be able to pass data or params
with the close events so that the close handlers can differentiate between
the modal being dismissed/cancelled or closed/resolved with a value/success
result.

The event seemingly already contains a canceled property, but this is
always false:

โ€”
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/euvl/vue-js-modal/issues/353#issuecomment-438071154,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABdxrrT3ijFlxjTXi7OjgJJNoTSumyZlks5uugZygaJpZM4YOyeI
.

O.o

you can use before-close, closed events
This doesn't work for dynamic modals because in this case the event.params is undefined.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

at0g picture at0g  ยท  3Comments

heykkyu picture heykkyu  ยท  4Comments

dland512 picture dland512  ยท  4Comments

uptownhr picture uptownhr  ยท  4Comments

Max64 picture Max64  ยท  4Comments