@alpinejs/docs 3.8.0-revision.2 → 3.8.0-revision.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alpinejs/docs",
3
- "version": "3.8.0-revision.2",
3
+ "version": "3.8.0-revision.3",
4
4
  "description": "The documentation for Alpine",
5
5
  "author": "Caleb Porzio",
6
6
  "license": "MIT"
@@ -157,9 +157,9 @@ And like most expressions in Alpine, you can always use the result of a JavaScri
157
157
  <a name="bind-directives"></a>
158
158
  ## Binding Alpine Directives Directly
159
159
 
160
- `x-bind` allows you to bind an object of different properties to an element.
160
+ `x-bind` allows you to bind an object of different directives and attributes to an element.
161
161
 
162
- The object keys are the directives (can be any directive including modifiers), and the values are callbacks to be evaluated by Alpine.
162
+ The object keys can be anything you would normally write as an attribute name in Alpine. This includes Alpine directives and modifiers, but also plain HTML attributes. The object values are either plain strings, or in the case of dynamic Alpine directoves, callbacks to be evaluated by Alpine.
163
163
 
164
164
  ```alpine
165
165
  <div x-data="dropdown()">
@@ -0,0 +1,36 @@
1
+ ---
2
+ order: 3
3
+ title: bind()
4
+ ---
5
+
6
+ # Alpine.bind
7
+
8
+ `Alpine.bind(...)` provides a way to re-use [`x-bind`](/directives/bind#bind-directives) objects within your application.
9
+
10
+ Here's a simple example. Rather than binding attributes manually with Alpine:
11
+
12
+ ```alpine
13
+ <button type="button" @click="doSomething()" :disabled="shouldDisable"></button>
14
+ ```
15
+
16
+ You can bundle these attributes up into a reusable object and use `x-bind` to bind to that:
17
+
18
+ ```alpine
19
+ <button x-bind="SomeButton"></button>
20
+
21
+ <script>
22
+ document.addEventListener('alpine:init', () => {
23
+ Alpine.bind('SomeButton', () => ({
24
+ type: 'button',
25
+
26
+ '@click'() {
27
+ this.doSomething()
28
+ },
29
+
30
+ ':disabled'() {
31
+ return this.shouldDisable
32
+ },
33
+ }))
34
+ })
35
+ </script>
36
+ ```
@@ -3,7 +3,7 @@ order: 1
3
3
  title: data()
4
4
  ---
5
5
 
6
- # `Alpine.data`
6
+ # Alpine.data
7
7
 
8
8
  `Alpine.data(...)` provides a way to re-use `x-data` contexts within your application.
9
9
 
@@ -3,7 +3,7 @@ order: 2
3
3
  title: store()
4
4
  ---
5
5
 
6
- # `Alpine.store`
6
+ # Alpine.store
7
7
 
8
8
  Alpine offers global state management through the `Alpine.store()` API.
9
9