'AlpineJS disable x-on:click if some condition happened
My Issue:
I want to disable the x-on:click
on the step = 1
.
So if you are on the website and are currently on step = 1
the button wont work, it only works if step = 2
gets triggered. Is something like that possible with AlpineJS?
The code:
<a href="#" x-on:click="step = 1, checkout = ! checkout">Clicking</a>
Solution 1:[1]
You could simply attach the handler only if the step is > 1 with f.e. the logical AND operator:
<a href="#" x-on:click="step > 1 && yourClickHandler()">Clicking</a>
In that case you should write a method yourClickHandler
where you do the stuff you want.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | demhadesigns |