laravellaravel-livewirelaravel-10laravel-livewire-wiremodel

using livewire 3 and laravel 10.10 [simple input data binding is not working]


I am working in:

Livewire 3, Laravel version is 10.10, PHP 8.2.4

I am trying to bind simple data with simple code but its not working, I am not sure why? Can you please help me? Livewire actions functions on click working, but data binding not updating data while typing in input field.

user.blade.php

<div>
    <input type="text" wire:model="name" id="description">
    Hi! My name is {{ $name }}
    <script>
        console.log("Livewire JavaScript loaded and working!");
    </script>
</div>

User.Php

namespace App\Livewire;

use Livewire\Component;

class User extends Component
{

    public $name = 'ali';


    public function render()
    {

        return view('livewire.user');
    }
}

On page load Output shows "ali" in the input field, but when I type more characters in input fields its not updating variable value.


Solution

  • In the documentation you can read : By default, Livewire only sends a network request when the form is submitted (or any other action is called), not while the form is being filled out.

    change your input code as below :

    <input type="text" wire:model.live="name" id="description">