I dont think onended is a native alpine listener?
My guess would be
<video src="..." x-on:onended="show=false"></video>
or
<video src="..." @onended="show=false"></video>
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Here's my simple AlpineJS code -
<div x-data="{show: true}">
<video src="..." onended="show=false"></video>
</div>
I'm wondering why is this not working? No error is thrown.
@thebigk No, onEnded (a ‘plain’ event listener attribute) is expected to contain plain JavaScript – that’s why onEnded="alert('xyz')" works. Technically, key=value is valid JavaScript, but it requires that you already have a plain JavaScript (not Alpine) variable called key and one called value. If you do, then it will set the value of key to be whatever the value of value is.
Alpine doesn’t use plain event listeners at all; it ignores them completely. It only uses its own special event listeners that begin with x-. Anything that interacts with Alpine must be in Alpine event listener attributes, not plain ones.
Take this as an example:
<video onEnded="var x = 5" x-on:ended="x = 5" />
When the video finishes playing, the browser will fire the ended event. That event will be caught by two different event listeners here:
x in the global scope and set its value to 5x on the JavaScript object that represents this particular Alpine component, and set its value to 5So you will end up with two different variables called x: one is a global JavaScript variable in the window/document scope, and you can use any plain JavaScript to retrieve it (such as the console in your browser); the other is an object property belonging to the Alpine object that represents the component in which the video resides.
Please or to participate in this conversation.