@alpinejs/docs 3.15.3 → 3.15.5
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
|
@@ -320,6 +320,58 @@ This is handy for things like real-time form-validation where you might not want
|
|
|
320
320
|
<span x-show="username.length > 20">The username is too long.</span>
|
|
321
321
|
```
|
|
322
322
|
|
|
323
|
+
<a name="change"></a>
|
|
324
|
+
### `.change`
|
|
325
|
+
|
|
326
|
+
`.change` syncs the data only when the input loses focus and its value has changed (the native `change` event). This is functionally equivalent to `.lazy`.
|
|
327
|
+
|
|
328
|
+
```alpine
|
|
329
|
+
<input type="text" x-model.change="username">
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
<a name="blur"></a>
|
|
333
|
+
### `.blur`
|
|
334
|
+
|
|
335
|
+
`.blur` syncs the data when the input loses focus, regardless of whether the value has changed.
|
|
336
|
+
|
|
337
|
+
```alpine
|
|
338
|
+
<input type="text" x-model.blur="email">
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
<a name="enter"></a>
|
|
342
|
+
### `.enter`
|
|
343
|
+
|
|
344
|
+
`.enter` syncs the data when the user presses the Enter key. This is useful for search fields where you want to trigger an action only when the user explicitly submits.
|
|
345
|
+
|
|
346
|
+
```alpine
|
|
347
|
+
<input type="text" x-model.enter="search">
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
> Note: `.enter` does not prevent the default behavior. If the input is inside a form, the form will still submit.
|
|
351
|
+
|
|
352
|
+
<a name="combining-event-modifiers"></a>
|
|
353
|
+
### Combining Event Modifiers
|
|
354
|
+
|
|
355
|
+
The `.change`, `.blur`, and `.enter` modifiers can be combined to sync on multiple events. This is useful when you want to give users flexibility in how they submit data.
|
|
356
|
+
|
|
357
|
+
```alpine
|
|
358
|
+
<!-- Sync on blur OR enter -->
|
|
359
|
+
<input type="text" x-model.blur.enter="search" placeholder="Press Enter or click away">
|
|
360
|
+
|
|
361
|
+
<!-- Sync on change, blur, OR enter -->
|
|
362
|
+
<input type="text" x-model.change.blur.enter="message">
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
<!-- START_VERBATIM -->
|
|
366
|
+
<div class="demo">
|
|
367
|
+
<div x-data="{ search: '' }">
|
|
368
|
+
<input type="text" x-model.blur.enter="search" placeholder="Press Enter or click away">
|
|
369
|
+
|
|
370
|
+
<div class="pt-4">Search: <span x-text="search"></span></div>
|
|
371
|
+
</div>
|
|
372
|
+
</div>
|
|
373
|
+
<!-- END_VERBATIM -->
|
|
374
|
+
|
|
323
375
|
<a name="number"></a>
|
|
324
376
|
### `.number`
|
|
325
377
|
|
|
@@ -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.15.
|
|
36
|
+
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.15.5/dist/cdn.min.js"></script>
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
That's it! Alpine is now available for use inside your page.
|