Skip to content

Commit 1ab7b6b

Browse files
authored
📝 Updates docs with notes for x-data usage (#4307)
1 parent cfe9499 commit 1ab7b6b

File tree

9 files changed

+23
-4
lines changed

9 files changed

+23
-4
lines changed

packages/docs/src/en/directives/bind.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ If `x-bind:` is too verbose for your liking, you can use the shorthand: `:`. For
2424
<input type="text" :placeholder="placeholder">
2525
```
2626

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+
2729
<a name="binding-classes"></a>
2830
## Binding classes
2931

packages/docs/src/en/directives/for.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ You may also pass objects to `x-for`.
5151

5252
There are two rules worth noting about `x-for`:
5353

54-
>`x-for` MUST be declared on a `<template>` element.
54+
> `x-for` MUST be declared on a `<template>` element.
5555
> That `<template>` element MUST contain only one root element
5656
5757
<a name="keys"></a>
@@ -110,6 +110,8 @@ If you need to simply loop `n` number of times, rather than iterate through an a
110110

111111
`i` in this case can be named anything you like.
112112

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+
113115
<a name="contents-of-a-template"></a>
114116
## Contents of a `<template>`
115117

packages/docs/src/en/directives/id.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ title: id
44
---
55

66
# x-id
7+
78
`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.
89

910
`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:
3031
</div>
3132
```
3233

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)

packages/docs/src/en/directives/if.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ Because of this difference in behavior, `x-if` should not be applied directly to
1515
</template>
1616
```
1717

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)
1919
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.

packages/docs/src/en/directives/model.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ Now when the `<button>` is clicked, the input element's value will instantly be
8383
</div>
8484
<!-- END_VERBATIM -->
8585

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+
8688
<a name="textarea-inputs"></a>
8789
## Textarea inputs
8890

packages/docs/src/en/directives/on.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ Here's the same component as above, but using the shorthand syntax instead:
2626
<button @click="alert('Hello World!')">Say Hi</button>
2727
```
2828

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+
2931
<a name="the-event-object"></a>
3032
## The event object
3133

packages/docs/src/en/directives/ref.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ title: ref
2222
</div>
2323
</div>
2424
<!-- 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)

packages/docs/src/en/directives/transition.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ If you wish to customize the durations specifically for entering and leaving, yo
6565
>
6666
```
6767

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+
6870
<a name="customizing-delay"></a>
6971
### Customizing delay
7072

packages/docs/src/en/start-here.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ Everything in Alpine starts with an `x-data` directive. Inside of `x-data`, in p
7171

7272
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.
7373

74+
> `x-data` is required on a parent element for most Alpine directives to work.
75+
7476
[→ Read more about `x-data`](/directives/data)
7577

7678
Let's look at `x-on` and see how it can access and modify the `count` property from above:

0 commit comments

Comments
 (0)