forked from alpinejs/alpine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
51 lines (42 loc) · 1.59 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<html>
<!-- <script src="./packages/intersect/dist/cdn.js" defer></script>
<script src="./packages/morph/dist/cdn.js" defer></script>
<script src="./packages/history/dist/cdn.js"></script>
<script src="./packages/persist/dist/cdn.js"></script>
<script src="./packages/focus/dist/cdn.js"></script>
<script src="./packages/mask/dist/cdn.js"></script>
<script src="./packages/ui/dist/cdn.js" defer></script> -->
<script src="./packages/alpinejs/dist/cdn.js" defer></script>
<!-- <script src="//cdn.tailwindcss.com"></script> -->
<script src="//cdn.tailwindcss.com"></script>
<div x-data="{ users: [{ name: 'lebowski' }] }">
<template x-for="(user, idx) in users">
<span x-text="users[idx].name" x-yo></span>
</template>
<button @click="users = []">Reset</button>
</div>
<!-- Play around here... -->
<div x-data>
<div id="thing" x-yo>i do not belong here...</div>
<br>
<br>
<br>
<br>
<button @click="document.getElementById('thing').remove()">remove</button>
</div>
<script>
document.addEventListener('alpine:init', () => {
Alpine.directive('yo', (el, {}, { cleanup }) => {
cleanup(() => {
console.log('removed')
})
})
})
</script>
<div x-data="{ users: [{ name: 'lebowski' }] }">
<template x-for="(user, idx) in users">
<span x-text="users[idx].name" x-yo></span>
</template>
<button @click="users = []">Reset</button>
</div>
</html>