Property mutation in Alpine CSP
Mutations in Alpine attributes are common in regular Alpine:
This again is not possible in Alpine CSP. Instead, extract the mutation into a method:
Tip
See hyva.createBooleanObject for a way to reduce this type of boilerplate code.
Passing arguments
Passing arguments to methods called from Alpine attributes is impossible in Alpine CSP.
The alternative is using data attributes.
Alpine variables are available as properties of this
, for example, this.$event
can be used in any event callback.
The same is true for iteration variables declared with x-for
.