Prevent Toast from being overridden

I implemented a toast service following this article:

https://www.syncfusion.com/kb/13421/show-or-hide-toast-from-any-page-using-service-in-blazor

The only problem i have with this is that when you add another button to trigger a different toast shortly after the first one, the first toast get overridden (title and content gets the value of second toast) .

I include a zip file with 2 buttons on the index page that will trigger 2 different toast. I want the first toast to not be overridden by the second toast.


Attachment: ShoworhidetoastusingserviceinBlazor_fe9fc159.zip

1 Reply 1 reply marked as answer

VY Vinothkumar Yuvaraj Syncfusion Team November 24, 2022 01:31 PM UTC

Hi Pieterjan,


Your reported issue can be resolved by passing the ToastModel with the ShowAsync method of Toast control.


Code snippet:

ToastComponent.razor

protected override void OnInitialized()

    {

ToastService.ShowToastTrigger += (ToastOption options) =>

        {

            InvokeAsync(() =>

            {

                this.Toast.ShowAsync(new ToastModel() { Title = options.Title, Content = options.Content });


            });

        };

    }


Please find the attached sample for your reference.


Best Regards,

Vinothkumar

If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.


Attachment: Blazor_ffe3c56a.zip

Marked as answer
Loader.
Up arrow icon