1,134 questions
21
votes
7
answers
34k
views
Reusable Alpine.js components?
How do I use Alpine.js to create a reusable component and display it? E.g., maybe I want to define an generic Alpine.js button component that changes text and color from parameters, then have my ...
21
votes
4
answers
38k
views
Hover over dropdown with Alpine JS
i wanna build a menu that is shown on mouseover and displays elements:
category:
- sub-category1
- sub-category2
I managed to accomplish that, but my problem is that when i hover over the menu and it ...
19
votes
2
answers
28k
views
Refreshing data after-the-fact in AlpineJS
I'm using Alpine to display a list of items that will change. But I can't figure out how to tell Alpine to refresh the list of items once a new one comes back from the server:
<div x-data=" ...
14
votes
4
answers
11k
views
How to prevent alpine.js modal from showing every time i refresh the page
i'm using alpine.js for my project and I have a modal that works well with alpine.js, my problem is that whenever you refresh the page, it shows for a second or two (while the page loads) and then ...
12
votes
5
answers
48k
views
Force a full page reload in Livewire
I use Livewire and Alpine with Laravel 8.
I have a page with a Datatable (jQuery) and a Bootstrap modal.
The table is filled with some data from a list of model instances.
When I click on a button in ...
9
votes
1
answer
29k
views
AlpineJS: How can I add a class to an element conditionally?
I have an array of messages being pulled into view thanks to Laravel Echo, Livewire, and AlpineJS.
<div class="mt-4 rounded-lg p-6"
x-data="{{ json_encode(['messages' => $...
9
votes
1
answer
20k
views
AlpineJS for dynamic select menu
Would like to be able to use Alpine.js to for a dropdown select form. When you select a particular option from the select menu the page insert a set of related records. How would I accomplish ...
8
votes
2
answers
11k
views
How to re-init the AlpineJS component after Livewire re-renders?
I have an alert component that I hide using AlpineJS but I want it to be visible again after Livewire re-renders.
Showing the alert using Livewire component
@if(Session::has('success'))
<x-...
8
votes
1
answer
10k
views
How to make flatpickr datepicker reactive in livewire / alpinejs app?
In my laravel 7 /livewire 1.3 / alpinejs 2 project
I added flatpickr datepicker from https://flatpickr.js.org
datepicker works ok, but reactive does not work. In the code below
$current_operation_date ...
8
votes
4
answers
19k
views
Alpine nested x-data
I am trying to learn Alpine and I am testing out nested x-data. I came across a GitHub issue with nested x-data. They provided a solution which I wanted to try out myself. However, when I try to ...
8
votes
6
answers
17k
views
How to check and uncheck all checkboxes by clicking one checkbox using alpine js
i am trying to use alpine js to check or uncheck all the boxes by checking or unchecking the select all checkbox respectively using alpine js, can any one please point me in the right direction... ...
8
votes
2
answers
15k
views
Add and Remove dom elements using alpine JS
I am trying to build a custom add and remove entire div element from an array using alpine JS, here is my code which is working but instead of removing from the exact remove button click it will ...
8
votes
2
answers
8k
views
Alpine Expression Error: Cannot set properties of null (setting '_x_dataStack')
I created a simple countdown with Alpine JS, but when timer is 0, I have an error.
First declare in x-data the function appTimer.
<div x-data="appTimer()">
<div x-show="...
8
votes
1
answer
1k
views
TinyMCE 4 - allow AlpineJS attributes for all HTML tags
I want to allow all Alpine JS components (x-data, x-init, etc.) as attributes for all HTML tags in TinyMCE 4.
I tried to add them via a rule for extended_valid_attributes in different ways, but ...
8
votes
1
answer
9k
views
scroll to top of page - livewire component - alpine js
I have an app created with laravel livewire where I'm loading a livewire component with multiple nested components that display one at a time depending upon a status variable. When each nested ...
8
votes
2
answers
5k
views
Tailwind CSS & Alpine JS transition out issue
I've got a very simple button & modal combo working inside Tailwind & Alpine - https://jsfiddle.net/0pso5cxh/
My issue is that on the leave transition (cancel button or close icon), none of ...
7
votes
3
answers
29k
views
How to properly add conditional class to Alpine JS x-for template?
I'm trying to iterate through a loop and add a conditional class to each element above 4 items for some resposive styling with tailwindcss.
Previously I had the loop adding in some other class, which ...
7
votes
2
answers
9k
views
How to execute multiple statements within a single Alpine.js attribute?
I would like to execute multiple statements within a single Alpine.js event handler (however, I believe it could be generalized to any attribute).
An example of what I would like to achieve:
<...
7
votes
4
answers
20k
views
How to access a property or a method of alpine.js parent component from a child component?
This is kind of an example scenario what the problem looks like,
<div x-data="{ count : 0 }">
<div x-data>
<span x-text="count"></span>
<button x-on:...
7
votes
1
answer
8k
views
Multiple class bindings in AlpineJS?
I'm trying to attach two :class bindings to a single element within an x-for loop. Usually this could be achieved by passing in a single object with multiple key:value pairs. In this instance however, ...
7
votes
3
answers
10k
views
Alpine.js - nested components
I have code like this with nested components:
<html>
<head>
<script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js" defer></script>
</...
7
votes
1
answer
17k
views
Toggle elements with class using Alpine JS?
I'm trying out Alpine JS and coming from jQuery. How can I do this in Alpine jS?
$('a').on('click', function(e) {
$('div').not('.' + $(this).data('class')).hide('slow');
$('.' + $(this).data('...
7
votes
3
answers
1k
views
Binded input value does not appear in request
I am trying to bind backAfterSaveStatus value to hidden input and for some reason then form is submited backAfterSave value is null.
After that I go back and submit form again - backAfterSave value is ...
6
votes
5
answers
8k
views
Is there a proper way to wire up Trix editor with Livewire?
When wiring together Trix editor content with Livewire, I am stumbling into problems. I believe that the issue is that when Livewire receives content from Trix, the content is swapped out and Trix ...
6
votes
1
answer
4k
views
Alpine.js - how to auto hide a flash message?
How can I auto-hide a flash message in Alpine.js? (Say I want it to disappear after 4 seconds)
<div class="flex mx-auto justify-between left-0 bottom-0 z-40">
<div class="...
6
votes
1
answer
16k
views
How to make timer in alpine.js app with time interval
With alpine.js 2 I try to make timer with definition in footer (which is set for all layout) of the app :
<div>
<div x-data="appFooterComponent()" x-init=" console.log('...
6
votes
3
answers
15k
views
Alpine.js how to watch for changes for radio button
Suppose I have this html and I want to do something each time user changes the pet:
<input type="radio" id="cat" name="pet" value="cat">
<input type=&...
6
votes
1
answer
10k
views
Combine x-show & x-text toggle in alpine.js
I am new to alpine.js and i need to toggle the innerText of an element, does anyone know ho can i combine showing an element and changing the innerText of another element? here is my code
<div ...
6
votes
1
answer
11k
views
Alpine JS not correctly update x-model
I have a problem with the selected option in simple Alpine form part. My selectbox get its values from an api. The x-model is set before the fetch. The selectbox sometimes shows the correct selected ...
6
votes
1
answer
2k
views
Livewire and Flatpickr - fails after rerender
This may be a basic question, but I'm struggling. Essentially I have a livewire component that updates an array of flight information that a user enters. Whenever the components get rerendered, the ...
6
votes
1
answer
5k
views
Skip a loop in alpine.js with x-if
I use this loop
<form action="/" method="POST">
<template x-for="(deck, index) in $store.cart.decks">
<div x-show="$store.cart.total(index) &...
6
votes
1
answer
9k
views
AlpineJS @click.away does not hide/remove the element
I am new to Alpine, and I am wondering why my @click.away does not work. It should hide/remove the dropdown from the page.
Live preview: https://codepen.io/fossil01/pen/XWRNqRz
<li class="...
6
votes
1
answer
4k
views
Why is alpinejs @click handler calling my console.log twice
I am wondering why this html / alpinejs is generating multiple console log entries when the button is clicked.
<script src="https://unpkg.com/[email protected]/dist/cdn.min.js"></script>
...
5
votes
3
answers
11k
views
Alpinejs x-on:click not working, attaching it to a parent div item
I cannot get the console log after clicking on this element.However changing div to button will fetch result.
Here is my code snippet.
<div class="navbar">
<div x-on:click=...
5
votes
3
answers
13k
views
Uncaught (in promise) TypeError: Cannot read properties of null (reading 'fingerprint') Laravel Livewire
I've made a multiple file-upload component using Laravel Livewire. After the upload is complete I want to display the uploaded files without reloading the page, like so:
<div class="grid grid-...
5
votes
1
answer
9k
views
Alpine.js - Show an input field and add focus to it at the same time
I have a button, and when a user clicks it, an input element should be shown and it should have focus.
I tried this:
<div x-data="{ show: false }">
<input x-show="show&...
5
votes
1
answer
14k
views
Problem to concatenate AlpineJS x-text and HREF property
I have a Datatable table being fed by AlpineJS:
<template x-for = "user in users": key = "user.Id">
In x-for, I have the value of user.Id that I can list in a SPAN field, with the instruction x-...
5
votes
1
answer
18k
views
alpinejs Checkbox checked on init or based on x-modal not working
When loading alpinejs it uncheckes all checkboxes, i don't know why it is doing so but it is.
<div x-data="{ colors: [orange] }">
<input type="checkbox" value="...
5
votes
1
answer
7k
views
Search/filter based on a menu list with AlpineJS
I'm fairly new to Alpine.js and looking to create a simple search/filter input to a list of items.
I've seen some examples using <template>, but im not interested in that particular technique.
...
5
votes
1
answer
6k
views
Dynamically set name attribute of input field in loop with AlpineJS
I'd like to set the name attribute of hidden input fields in a loop with AlpineJS. I've tried x-bind:name but that doesn't work.
I think this doesn't work because of the x-model in how todos are added:...
5
votes
2
answers
2k
views
Translating Alpine.js x-transitions to Vue.js transition classes?
So, I have a slight conceptual problem. I'll also admit I am primarily a back end developer and loose front end developer looking to learn better UI/UX principles/frameworks etc so apologies in ...
5
votes
4
answers
2k
views
Alpine.Js - How can i Upgrade
I am using
https://github.com/laravel-frontend-presets/tall
and unable to upgrade the alpine.js version
I tried changing package.json
Changed from
"alpinejs": "^2.8.2",
Changed to
&...
5
votes
2
answers
16k
views
How To Make A Full Screen Modal In Tailwind
I'm trying to build a modal using Tailwind in alpine, point me to the right direction on building a full screen modal using Tailwind CSS and alpine js
5
votes
3
answers
9k
views
Get data attributes on click element alpinejs
<li class="">
<a @click.prevent="download(e)" data-video="video_id" data-url="{{ base_url('tools/download_thumbnail') }}" data-quality="maxres&...
5
votes
4
answers
5k
views
how to scroll to first validation error message in livewire laravel
I am new in livewire. i am working on registration process of user. Register form is quite big and validations also working fine to me. The problem is when user submits the form validations came but ...
5
votes
3
answers
1k
views
How to Install Alpine JS 3 with Rails 6.1 via Webpacker
Ever since AlpineJS upgraded to Alpine 3, I haven't been able to get it working with Rails 6 and webpacker, I've only been able to get it working when linking to the CDN version of Alpine.
In the past ...
4
votes
1
answer
4k
views
How to hide flashing dialog content when page is loading?
On tailwindcss, Alpinejs page I use modal which is opened by click on button.
Problem is that while page is loading I see flashing dialog content.
I tried to set hidden class to modal window and in ...
4
votes
1
answer
33k
views
Tracking input change in alpine.js
I'm learning alpine.js and trying to capture the user input value.
I have used "x-on:input" but its not calling the function
Below is the simple form input
<input type="email" ...
4
votes
1
answer
29k
views
Alpine.js: How do I access x-data from a function in an external file?
I'm just starting out with Alpine.js, I understand the basics but I'm having trouble applying them when moving functions outside of inline script tags.
For example, in index.html:
<div x-data="...
4
votes
2
answers
5k
views
How to Convert Disable submit button from jQuery to alpinejs?
I want to know How I can Convert Disable submit button from jQuery to alpine js?
The Code :
<form>
<input type="text" class="input-field" placeholder="Enter you ...