github alpinejs/alpine v1.7.0

latest releases: v3.14.3, v3.14.2, v3.14.1...
4 years ago

Added

  • The ability to return a callback from x-init and it will run AFTER Alpine makes it's initial DOM updates (similar to the mounted() hook in VueJS, or the current, but now deprecated, x-mounted hook)
<div x-data="initialData()" x-init="init()">
    <span x-text="foo" x-ref="span">bar</span>
</div>
<script>
function initialData() {
    return {
        foo: 'baz',
        init() {
            this.$refs.span.innerText // 'bar'

            return () => {
                this.$refs.span.innerText // 'baz'
            }
        }
    }
}
</script>

Deprecated

  • x-created and x-mounted are now deprecated and will be removed in 2.0

Don't miss a new alpine release

NewReleases is sending notifications on new releases.