Created
July 23, 2022 18:45
-
-
Save TWithers/6224f339c5e4b77039b9bbec525d18ae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>List</h1> | |
<ul | |
x-data="{items: @entangle('items').defer, newItem:'', errors:{}}" | |
@validation.window="errors = $event.detail"> | |
<template x-for="(item, index) in items"> | |
<li x-bind:class="errors['item.'+index'] ? 'text-danger' : ''"> | |
<span x-text="item"></span> | |
<i x-show="errors['item.'+index']" | |
x-text="errors['item.'+index] ? errors['item.'+index].join(' ') : ''" | |
> | |
</i> | |
</li> | |
</template> | |
</ul> | |
<input type="text" x-model="newItem" placeholder="Enter something"> | |
<button type="button" @click="items.push(newItem)">Append</button> | |
<button type="button" @click="$wire.persistItems()">Persist</button> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment