arthurvasconcelos / vue-izitoast

Elegant, responsive, flexible and lightweight notification plugin implemented for Vue 2 of iziToast
https://arthurvasconcelos.com.br/vue-izitoast
Apache License 2.0
133 stars 21 forks source link

[ Help ] Pass a Parameter when a Method is called #13

Open JojoMig opened 5 years ago

JojoMig commented 5 years ago

Hi, is there a way to pass a parameter (object or not) when a method is called, so any Button Actions can have this parameter to process? Like: this.$toast.show('Welcome!', 'Hey', {parameters}, notificationSystem.options.show); any help is appreciated thanks in advance

arthurvasconcelos commented 5 years ago

Hi, @JojoMig when you are using Button Actions you already define the parameters that it uses in the parameter object that you pass to show method.

buttons: [
        ['<button>Ok</button>', function (instance, toast) {
            alert("Hello world!");
        }, true], // true to focus
        ['<button>Close</button>', function (instance, toast) {
            Vue.toast.hide(toast, {
                transitionOut: 'fadeOutUp',
                onClosing: function(instance, toast, closedBy){
                    console.info('closedBy: ' + closedBy); // The return will be: 'closedBy: buttonName'
                }
            });
        }]
    ]

This solves your problem or are you trying to do something else? If so, please can you provide an example?