Vue-js-modal: Pass data back from modal

Created on 17 Mar 2018  路  4Comments  路  Source: euvl/vue-js-modal

With dynamic module, how to return data (e.g. user input) back to caller component (where this.$modal.show(...) called)?

question

Most helpful comment

When I first started using it, going from the examples I was under the impression I was able to set handlers for events emitted from inside the modal in the 4th parameter of $modal.show(), like it does for before-close and so on. That seems more intuitive and versatile for me if it was an option, than going through an event bus or vuex.

For example inside the modal $emit('modal-event', payload), and showing the modal like this:

this.$modal.show(
    ModalComponent,
    {},
    { height: 'auto' },
    {
        'modal-event': payload => {
            console.log(payload);
        },
    },
);

All 4 comments

through vuex or observers or global event bus

I chose to use event bus for this in my app, but it's interesting did you consider API with returning promise from $modal.show() method? Usually we need data from modal in place where we called it, and it would be very familiar for developers coming from angularjs.

not really, i feel like its up for developer how to implement it (as it is doable task) and has nothing to do with showing modal (which this library is build for).

When I first started using it, going from the examples I was under the impression I was able to set handlers for events emitted from inside the modal in the 4th parameter of $modal.show(), like it does for before-close and so on. That seems more intuitive and versatile for me if it was an option, than going through an event bus or vuex.

For example inside the modal $emit('modal-event', payload), and showing the modal like this:

this.$modal.show(
    ModalComponent,
    {},
    { height: 'auto' },
    {
        'modal-event': payload => {
            console.log(payload);
        },
    },
);
Was this page helpful?
0 / 5 - 0 ratings

Related issues

chris-rowe picture chris-rowe  路  4Comments

dland512 picture dland512  路  4Comments

MacgyverMartins picture MacgyverMartins  路  4Comments

ar53n picture ar53n  路  4Comments

a3020 picture a3020  路  5Comments