HT-ftw's avatar

Livewire 3, data not binding problem

Hi Everyone,

for quite a while I'm struggling with the issue below. I have this simple component:

namespace App\Livewire\Livewiretest;

use Livewire\Component;

class Livewiretest extends Component
{
    public $test='hello';
    
    public function render()
    {
        return view('livewire.livewiretest.livewiretest');
    }
}

and

the following template:

<div>

    <input type="text" wire:model="test">

    <p>this is a: {{ $test }}</p>
</div>

In my understanding when I write something in the input the $test variable should be updated and should display however it is not working and nothing is happening.

If I change the code like this:

namespace App\Livewire\Livewiretest;

use Livewire\Component;

class Livewiretest extends Component
{
    public $test='hello';
    
    public function render()
    {
        return view('livewire.livewiretest.livewiretest');
    }

    public function save()
    {
        
    }
<div>
    {{-- Stop trying to control. --}}

    <form>
    <input type="text" wire:model="test">
    <button wire:click.prevent="save()">Submit</button>
    </form>

    <p>this is a: {{ $test }}</p>
</div>

and this works after submitting the $test variable is updated.

So can anybody help me and explain what I am doing wrong?:) Thanks HT

0 likes
9 replies
HT-ftw's avatar

I don't know why, but the code quotation removed the parent divs that are in the template code, so they are there :)

HT-ftw's avatar

Managed to fix the code presentation - sorry and once again thanks for any help

Snapey's avatar

Laravel Debugbar is a useful companion to Livewire as it shows the internal representation of the component and allows you see if the data is not being updated or if it is not being displayed correctly.

HT-ftw's avatar

Thanks great tool. Well it tells me that Ajax request is not triggered but unfortunately I still don't know why?

HT-ftw's avatar
HT-ftw
OP
Best Answer
Level 1

Got it solved If somebody struggles with similar issue you need to change

<input model.wire.live="test">

in Livewire 3 they require you to use .live

hope it helps if anybody will have similar issue

4 likes
PhillipMwaniki's avatar

@HT-ftw This doesn't work on my end. I've also tried it out with <input model:wire.live=""> but nothing worked.

ibrahimshiyam's avatar

@HT-ftw thanks a bunch. I had to create an account just to thank you for this. been stuck with this from last night. cheers

1 like

Please or to participate in this conversation.