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?
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.