Trouble with the Wizard
This may be more of a Livewire, but maybe someone here can point me in the right direction. I am trying to use Stripe Elements on the second step of a Wizard. But when you click Next to get to step 2, the component gets re-rendered, and some Javascript needs to run again to reinitialize the Stripe elements.
From the Stripe docs, I register their script and put the necessary JS code in a method called
initElements
which lives in the stripe-elements.js
file. I am able to manually run the initElements
method from the console, and then the Stripe Elements do appear.
I'm wondering:
Is there a way to prevent certain steps in a wizard from re-rendering when the next action is performed?
Is there a better/different way of approaching this?
What is the best way to call a javascript function after the component has been rendered? I did try listening for the next-wizard-step
event in my page's class with the following code, but the Stripe Elements still wouldn't show
I am registering the JS like this:
This is the schema for my wizard:
1 Reply
The previous issue was able to be resolved by simply adding
wire:ignore
to the root element I wanted Livewire to.. ignore for re-rendering. 🤦 Simple enough.
Now I'm stuck trying to figure out what is the right way of calling an Alpine function when the Next action button is clicked, but before requesting the next step?
On step two, I am collecting the billing information and when Next step is clicked, the information is sent to Stripe via an ajax request. I don't want the wizard to proceed to the next step until that request succeeds.
Since the click listener for the Next action is tied to the button's parent div (vendor/filament/schemas/resources/views/components/wizard.blade.php:172
), I'm having a hard time figuring out how to do this.
Below is the code I currently have, but it doesn't feel right, and while it does solve this scenario, the return '$dispatch(\'confirm-stripe\', $event)';
line causes the following error when submitting on the final step Filament\Actions\Exceptions\ActionNotResolvableException: An action tried to resolve without a name.
. If I comment out that line, it submits, but then the Stripe ajax call is obviously never made.
billing.blade
stripe-elements