Vue-js-modal: Setting data outside Modal? (Help)

Created on 4 Aug 2017  路  4Comments  路  Source: euvl/vue-js-modal

Hi!
Is it possible to set data or props inside a modal from outside, without giving it as props in the declaration?

Like, if I define a modal like this;
but I want to show it with different parameters, depending on where the 'show' is called, like for example like this;
@click="$modal.show('error-modal', 'data'));"
Is it possible to achieve this in some way?
Would greatly appreciate any help :)

question

Most helpful comment

Hey,

Try this:

@click="$modal.show('error-modal', { foo: 'bar' });

In modal component:

<template>
  <modal name="error-modal" @before-open="beforeOpen">
  ...
  </modal>
</template>
methods: {
  beforeOpen (event) {
    console.log(event.params) // <- your data is here
  }
}

For more a workign example look in demo -> ConditionalModal.vue

All 4 comments

Like a verification modal where you accept or deny deletion of a user, so you need to know what user is in question inside the modal :)

Hey,

Try this:

@click="$modal.show('error-modal', { foo: 'bar' });

In modal component:

<template>
  <modal name="error-modal" @before-open="beforeOpen">
  ...
  </modal>
</template>
methods: {
  beforeOpen (event) {
    console.log(event.params) // <- your data is here
  }
}

For more a workign example look in demo -> ConditionalModal.vue

Thank you so much mate!
This was exactly what I was looking for 馃憤

No probs 馃槃 Thanks for using the plugin!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

at0g picture at0g  路  3Comments

Max64 picture Max64  路  4Comments

ishetnogferre picture ishetnogferre  路  4Comments

dland512 picture dland512  路  4Comments

heykkyu picture heykkyu  路  4Comments