Livewire: Bind refresh not working from server to client for input type

87 views Asked by At

I have a laravel livewire (v3) component that contains an input field. I'm trying to get the displayed field to refresh after the bound (bind-ed) property is updated server-side.

Livewire component:

<?php

namespace App\Livewire\MyNamespace;

use Livewire\Component;

class Create extends Component
{

    public function rules()
    {
        return [
            'doSomething' => 'required',
        ];
    }

    public $doSomething = '';

    public function add()
    {
        $this->doSomething = 'Welcome';
        $this->dispatch('$refresh');
    }

    public function render()
    {
        return view('livewire.create');
    }
}

The view is simple:

<div>
<button class="btn btn-primary" wire:click="add">Press me</button>
<input type="text" wire:model.live="doSomething">
Label: {{ $doSomething }}
</div>

When I press the button, the input field displayed isn't updated, but the text is rendered in the label - any ideas? Does an input binding only work one way, client to server?

2

There are 2 answers

0
Sammar malik On

Your code seems good. It should work as input binding works both ways i.e. client to server and server to client. Try clearing your application cache.

1
jtaboracastejon On

I was facing with the same issue, I was loading Alpine.JS twice one manually and the loaded by @livewirescripts, even if you didn't put the livewire tags JetStream load them if you use it