Caleb Porzio 5 лет назад
Родитель
Сommit
c34b08ca80
1 измененных файлов с 19 добавлено и 0 удалено
  1. 19 0
      README.md

+ 19 - 0
README.md

@@ -54,6 +54,25 @@ Alpine.start()
 </div>
 ```
 
+You can even use if for non-trivial things:
+*Pre-fetching a dropdown's HTML content on hover*
+```html
+<div x-data="{ open: false }">
+    <button
+        x-on:mouseenter.once="
+            fetch('/dropdown-partial.html')
+                .then(response => response.text())
+                .then(html => { $refs.dropdown.innerHTML = html })
+        "
+        x-on:click="open = true"
+    >Show Dropdown</button>
+
+    <div x-ref="dropdown" x-show="open" x-on:click.away="open = false">
+        Loading Spinner...
+    </div>
+</div>
+```
+
 ## Learn
 
 There are 7 directives available to you: