Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mfoq's avatar
Level 1

Alpine Expression Error: Unexpected token '}' Expression: "$wire."

I'm building a wizard using Livewire 3, alpine 3.4.2, the main wizard is a Livewire component and each wizard's step is a Livewire component too, the issue is after I click on the first step save button(to go to the next step) there's an error being shown in the console, I trace the code and I try to use dispatch, $wire.call, all options that we have the call component method but still face the same issue.

Error :

Alpine Expression Error: Unexpected token '}'

Expression: "$wire."

Uncaught SyntaxError: Unexpected token '}'

Main wizard :

View :

step one :

Step one View :

Livewire v3.5

Laravel v11.9

PHP 8.3

0 likes
1 reply
mfoq's avatar
mfoq
OP
Best Answer
Level 1

I encountered an issue where clicking the submit button inside a form wizard step (each step being a Livewire component) would trigger a traditional form submission, which was not the intended behavior.

The Problem:

Each step of my form wizard is a Livewire component, and each has a submit button. Initially, I was binding the submit action like this:

<x-button-loading x-on:click="$wire.submitBasicInfo" buttonName="Save" target="submitBasicInfo"/>

Without the .prevent modifier, clicking the button triggered the default form submission behavior. This caused the form to be submitted traditionally, interfering with the Livewire handling.

The Solution:

To resolve this, I used the .prevent modifier, which prevents the default form submission and allows Alpine.js and Livewire to handle the form logic properly:

<x-button-loading @click.prevent="$wire.submitBasicInfo" buttonName="Save" target="submitBasicInfo" />

By using @click.prevent, the default behavior is stopped, ensuring that the form submission is controlled by Livewire without a traditional form post occurring.

Please or to participate in this conversation.