Closed M-Abdullahi closed 4 years ago
You can wrap it in a promise and wait for the answer with onClosing
hook:
question: (message, title = 'Question') => {
return new Promise((resolve) => {
iziToast.question({
onClosing(_instance, _toast, closedBy) {
resolve(closedBy)
}
})
}
}
thank you @andreiscripcaru22. Your solution brought me back to the promise option that I was thinking about but didn't know how to implement. I decided to resolve the promise when the OK button was pressed shown below.
question: (message, title = 'Question') => {
return new Promise((resolve => {
iziToast.question({
title: title,
message: message,
timeout: 20000,
progressBar: false,
close: false,
overlay: true,
buttons: [
['<button><b>Confirm</b></button>', function (instance, toast, button, e, inputs) {
instance.hide({transitionOut: 'fadeOut'}, toast, 'button');
resolve();
}, false],
['<button>NO</button>', function (instance, toast, button, e) {
instance.hide({transitionOut: 'fadeOut'}, toast, 'button');
}]
],
onClosing(_instance, _toast, closedBy) {
// console.info('closedBy: ' + closedBy);
}
})
}));
}
Then calling it from my component as shown below
changeInvoiceDate() {
this.dateChangeForm.post('/accounting/invoices/' + this.invoiceid + '/change_date')
.then(() => {
this.showDateChangeForm = false;
toast.success('Invoice date was updated');
this.getInvoice();
})
.catch(error => toast.error(error.response.data.message))
},
Hi. Thank you for making this great notification package. I am comfortable in using the package to display notifications but having a hard time figuring out how to use it a dialogue option.
I have made a wrapper around the library as shown below
Then calling it from my vue component as shown below