Skip to content

2.1 Release

Compare
Choose a tag to compare
@jantinnerezo jantinnerezo released this 26 Dec 18:41
· 90 commits to master since this release
8cdf191

What's new?

  • Added PHP 8.0 support
  • Removed <x-livewire::confirm /> component
  • Added multiple confirmation alerts on a single livewire component
  • Refactor confirmation alerts to use livewire event listeners to handle callbacks.
  • Removed the need to use Alpine.js, it's no longer required.
  • Refactor Alpine.js code to vanilla js for alert confirmation.
  • Refactor alert javascript codes.
  • Added config.php file with default SweetAlert2 config.
  • Removed SweetAlert2 script tag, should no longer be included by default.

Breaking changes

Ditched the <x-livewire::confirm /> component.

In the previous version 2.0 you may add the <x-livewire::confirm /> and define the onConfirmed and onCancelled callback as props like the code below.

<x-livewire::confirm onConfirmed="confirmed" onCancelled="cancelled" />

However when you have multiple confirmation alerts in the same livewire component this is not be possible and can cause multiple calls of javascript code with Alpine.js which is required to make the confirmation works.

In the latest version which is 2.1 , the <x-livewire::confirm /> component is removed and you can directly add your callback methods to the confirm config in your livewire component class.

public function confirmed()
{
   //
}

public function cancelled()
{
   //
}

Register the callback methods as event listeners.

protected $listeners = [
      'confirmed',
      'cancelled'
];

Add the event listeners to the confirm config.

// Trigger action method
public function triggerConfirm()
{
    $this->confirm('Do you love Livewire Alert?', [
        'toast' => false,
        'position' => 'center',
        'showConfirmButton' => true,
        'cancelButtonText' => Nope,
        'onConfirmed' => 'confirmed', // Add the confirmed callback method here
        'onCancelled' => 'cancelled' // Add the cancelled callback method here
    ];
}

For more information please visit the documentation page: https://livewire-alert.jantinnerezo.com/