@alpinejs/docs 3.14.1-revision.2 → 3.14.2-revision.1

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.14.1-revision.2",
3
+ "version": "3.14.2-revision.1",
4
4
  "description": "The documentation for Alpine",
5
5
  "author": "Caleb Porzio",
6
6
  "license": "MIT"
@@ -24,6 +24,8 @@ If `x-bind:` is too verbose for your liking, you can use the shorthand: `:`. For
24
24
  <input type="text" :placeholder="placeholder">
25
25
  ```
26
26
 
27
+ > Despite not being included in the above snippet, `x-bind` cannot be used if no parent element has `x-data` defined. [→ Read more about `x-data`](/directives/data)
28
+
27
29
  <a name="binding-classes"></a>
28
30
  ## Binding classes
29
31
 
@@ -162,7 +164,7 @@ And like most expressions in Alpine, you can always use the result of a JavaScri
162
164
  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 directives, callbacks to be evaluated by Alpine.
163
165
 
164
166
  ```alpine
165
- <div x-data="dropdown()">
167
+ <div x-data="dropdown">
166
168
  <button x-bind="trigger">Open Dropdown</button>
167
169
 
168
170
  <span x-bind="dialogue">Dropdown Contents</span>
@@ -51,7 +51,7 @@ You may also pass objects to `x-for`.
51
51
 
52
52
  There are two rules worth noting about `x-for`:
53
53
 
54
- >`x-for` MUST be declared on a `<template>` element.
54
+ > `x-for` MUST be declared on a `<template>` element.
55
55
  > That `<template>` element MUST contain only one root element
56
56
 
57
57
  <a name="keys"></a>
@@ -110,6 +110,8 @@ If you need to simply loop `n` number of times, rather than iterate through an a
110
110
 
111
111
  `i` in this case can be named anything you like.
112
112
 
113
+ > Despite not being included in the above snippet, `x-for` cannot be used if no parent element has `x-data` defined. [→ Read more about `x-data`](/directives/data)
114
+
113
115
  <a name="contents-of-a-template"></a>
114
116
  ## Contents of a `<template>`
115
117
 
@@ -4,6 +4,7 @@ title: id
4
4
  ---
5
5
 
6
6
  # x-id
7
+
7
8
  `x-id` allows you to declare a new "scope" for any new IDs generated using `$id()`. It accepts an array of strings (ID names) and adds a suffix to each `$id('...')` generated within it that is unique to other IDs on the page.
8
9
 
9
10
  `x-id` is meant to be used in conjunction with the `$id(...)` magic.
@@ -30,4 +31,4 @@ Here's a brief example of this directive in use:
30
31
  </div>
31
32
  ```
32
33
 
33
-
34
+ > Despite not being included in the above snippet, `x-id` cannot be used if no parent element has `x-data` defined. [→ Read more about `x-data`](/directives/data)
@@ -15,6 +15,10 @@ Because of this difference in behavior, `x-if` should not be applied directly to
15
15
  </template>
16
16
  ```
17
17
 
18
- > Unlike `x-show`, `x-if`, does NOT support transitioning toggles with `x-transition`.
18
+ > Despite not being included in the above snippet, `x-if` cannot be used if no parent element has `x-data` defined. [→ Read more about `x-data`](/directives/data)
19
19
 
20
- > Remember: `<template>` tags can only contain one root level element.
20
+ ## Caveats
21
+
22
+ Unlike `x-show`, `x-if`, does NOT support transitioning toggles with `x-transition`.
23
+
24
+ `<template>` tags can only contain one root element.
@@ -83,6 +83,8 @@ Now when the `<button>` is clicked, the input element's value will instantly be
83
83
  </div>
84
84
  <!-- END_VERBATIM -->
85
85
 
86
+ > Despite not being included in the above snippet, `x-model` cannot be used if no parent element has `x-data` defined. [→ Read more about `x-data`](/directives/data)
87
+
86
88
  <a name="textarea-inputs"></a>
87
89
  ## Textarea inputs
88
90
 
@@ -26,6 +26,8 @@ Here's the same component as above, but using the shorthand syntax instead:
26
26
  <button @click="alert('Hello World!')">Say Hi</button>
27
27
  ```
28
28
 
29
+ > Despite not being included in the above snippet, `x-on` cannot be used if no parent element has `x-data` defined. [→ Read more about `x-data`](/directives/data)
30
+
29
31
  <a name="the-event-object"></a>
30
32
  ## The event object
31
33
 
@@ -22,3 +22,5 @@ title: ref
22
22
  </div>
23
23
  </div>
24
24
  <!-- END_VERBATIM -->
25
+
26
+ > Despite not being included in the above snippet, `x-ref` cannot be used if no parent element has `x-data` defined. [→ Read more about `x-data`](/directives/data)
@@ -65,6 +65,8 @@ If you wish to customize the durations specifically for entering and leaving, yo
65
65
  >
66
66
  ```
67
67
 
68
+ > Despite not being included in the above snippet, `x-transition` cannot be used if no parent element has `x-data` defined. [→ Read more about `x-data`](/directives/data)
69
+
68
70
  <a name="customizing-delay"></a>
69
71
  ### Customizing delay
70
72
 
@@ -33,7 +33,7 @@ This is by far the simplest way to get started with Alpine. Include the followin
33
33
  Notice the `@3.x.x` in the provided CDN link. This will pull the latest version of Alpine version 3. For stability in production, it's recommended that you hardcode the latest version in the CDN link.
34
34
 
35
35
  ```alpine
36
- <script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.14.1/dist/cdn.min.js"></script>
36
+ <script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.14.2/dist/cdn.min.js"></script>
37
37
  ```
38
38
 
39
39
  That's it! Alpine is now available for use inside your page.
@@ -52,7 +52,7 @@ Alpine.plugin(resize)
52
52
 
53
53
  The primary API for using this plugin is `x-resize`. You can add `x-resize` to any element within an Alpine component, and when that element is resized for any reason, the provided expression will execute with two magic properties: `$width` and `$height`.
54
54
 
55
- For example, here's a simple example of using `x-resize` do display the width and height of an element as it changes size.
55
+ For example, here's a simple example of using `x-resize` to display the width and height of an element as it changes size.
56
56
 
57
57
  ```alpine
58
58
  <div
@@ -81,7 +81,7 @@ For example, here's a simple example of using `x-resize` do display the width an
81
81
  <a name="document"></a>
82
82
  ### .document
83
83
 
84
- It's often useful to observer the entire document's size, rather than a specific element. To do this, you can add the `.document` modifier to `x-resize`:
84
+ It's often useful to observe the entire document's size, rather than a specific element. To do this, you can add the `.document` modifier to `x-resize`:
85
85
 
86
86
  ```alpine
87
87
  <div x-resize.document="...">
@@ -95,7 +95,7 @@ You can react to sorting changes by passing a handler function to `x-sort` and a
95
95
  </div>
96
96
  <!-- END_VERBATIM -->
97
97
 
98
- The `x-sort` handler will be called every time the sort order of the items change. The `$item` magic will contain the key of the sorted element (derived from `x-sort:item`), and `$position` will contain the new position of the item (staring at index `0`).
98
+ The `x-sort` handler will be called every time the sort order of the items change. The `$item` magic will contain the key of the sorted element (derived from `x-sort:item`), and `$position` will contain the new position of the item (starting at index `0`).
99
99
 
100
100
  You can also pass a handler function to `x-sort` and that function will receive the `item` and `position` as the first and second parameter:
101
101
 
@@ -71,6 +71,8 @@ Everything in Alpine starts with an `x-data` directive. Inside of `x-data`, in p
71
71
 
72
72
  Every property inside this object will be made available to other directives inside this HTML element. In addition, when one of these properties changes, everything that relies on it will change as well.
73
73
 
74
+ > `x-data` is required on a parent element for most Alpine directives to work.
75
+
74
76
  [→ Read more about `x-data`](/directives/data)
75
77
 
76
78
  Let's look at `x-on` and see how it can access and modify the `count` property from above: