Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect Button on the notification #1

Open
kmiesen opened this issue Oct 3, 2022 · 0 comments
Open

Redirect Button on the notification #1

kmiesen opened this issue Oct 3, 2022 · 0 comments

Comments

@kmiesen
Copy link

kmiesen commented Oct 3, 2022

Hello there,

I was trying to create a simple redirect button on the notification and looking at the documentation of Toast this is not easy with the current package.

I got it working localy by changing the package, I had this in mind:

Livewire.on('success', function(alert) {
      if (alert.modal !== null) {
          modalHide(alert.modal)
      }
      iziToast.success(Object.assign({}, {
              title: alert.options.title !== null &&
              alert.options.title !== void 0 ? alert.options.title : '',
              message: alert.message !== null &&
              alert.message !== void 0 ? alert.message : '',
              buttons: alert.options.redirect_button !== void 0 ? [
                  ['<button>' + alert.options.redirect_button.title + '</button>', function (instance, toast) {
                      window.location.href = alert.options.redirect_button.route;
                  }]
              ] : []
          },
          alert.options));
  });

This way u can add the following to the options:

'options' => [
    'redirect_button' => [
        'route' => route('x', ['x' => $x]),
        'title' => 'x'
    ]
]

This will result in a simple button that redirects u when clicked!

If this is already possible with the current code, please let me know how, if not, maybe consider adding this to the repo?

With kind regards,
Kars Miesen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant