Every pieces of js codes must be inside of a component, otherwise code won't run :)
There are 15 attributes in alpine.js
- x-data: state or component data
- x-bind: dynamically bind attributes
- x-on: for binding events
- x-text: show text but not html render
- x-html: ⚠ TODO
- x-model: modeling with input
- x-show: show an element based on condition
- x-transition: transition efffects on elements
- x-if: conditionaly add or remove elements
- x-for: loop for data
- x-init: run some code when element intialized
- x-effect: track changes for dependencies
- x-ref: reference to an elemtn
- x-cloak: an helper attribute for removing delay
- x-ignore: ignore a component by intialized by alpine
There are 6 properties
- $store: acces a global store registered by Alpine.store(...)
- $el: Reference the current DOM element
- $dispatch: Dispatch a custom browser event from the current element
- $watch:
- $refs
- $nextTick