@alpinejs/docs 3.9.0-revision.1 → 3.9.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
|
@@ -5,26 +5,24 @@ title: modelable
|
|
|
5
5
|
|
|
6
6
|
# x-modelable
|
|
7
7
|
|
|
8
|
-
`x-modelable` allows you to expose any
|
|
9
|
-
|
|
10
|
-
Typically this feature would be used in conjunction with a backend templating framework like Laravel Blade. It's useful for abstracting away Alpine components into backend templates and exposing state to the outside through `x-model` as if it were a native input.
|
|
8
|
+
`x-modelable` allows you to expose any Alpine property as the target of the `x-model` directive.
|
|
11
9
|
|
|
12
10
|
Here's a simple example of using `x-modelable` to expose a variable for binding with `x-model`.
|
|
13
11
|
|
|
14
12
|
```alpine
|
|
15
13
|
<div x-data="{ number: 5 }">
|
|
16
|
-
<div x-data="{ count: 0 }" x-modelable="count" x-model="
|
|
14
|
+
<div x-data="{ count: 0 }" x-modelable="count" x-model="number">
|
|
17
15
|
<button @click="count++">Increment</button>
|
|
18
16
|
</div>
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
Number: <span x-text="number"></span>
|
|
21
19
|
</div>
|
|
22
20
|
```
|
|
23
21
|
|
|
24
22
|
<!-- START_VERBATIM -->
|
|
25
23
|
<div class="demo">
|
|
26
24
|
<div x-data="{ number: 5 }">
|
|
27
|
-
<div x-data="{ count: 0 }" x-modelable="count" x-model="
|
|
25
|
+
<div x-data="{ count: 0 }" x-modelable="count" x-model="number">
|
|
28
26
|
<button @click="count++">Increment</button>
|
|
29
27
|
</div>
|
|
30
28
|
|
|
@@ -35,3 +33,4 @@ Here's a simple example of using `x-modelable` to expose a variable for binding
|
|
|
35
33
|
|
|
36
34
|
As you can see the outer scope property "number" is now bound to the inner scope property "count".
|
|
37
35
|
|
|
36
|
+
Typically this feature would be used in conjunction with a backend templating framework like Laravel Blade. It's useful for abstracting away Alpine components into backend templates and exposing state to the outside through `x-model` as if it were a native input.
|
|
@@ -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://unpkg.com/alpinejs@3.9.
|
|
36
|
+
<script defer src="https://unpkg.com/alpinejs@3.9.2/dist/cdn.min.js"></script>
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
That's it! Alpine is now available for use inside your page.
|