Why Livewire doesn't send ajax requests on my local System?

49 Views Asked by At

I'm new to Livewire and I'm following screencasts of livewire official website. I'm trying to change an input value and use it in next line as document of livewire3 says and my simple code is as same as video but AJAX requests are not sending.

This is My Class:

<?php

namespace App\Livewire;

use Livewire\Component;

class HelloWorld extends Component
{
    public $name = 'Mahdi';
    public function render()
    {
        return view('livewire.hello-world');
    }
}

Here is My Component:

<div>
    <input wire:model="name" type="text">
    {{ $name }}
</div>

And this is my Blade:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    @livewireStyles
</head>
<body>
    @livewire('hello-world')

    @livewireScripts
</body>
</html>

I have tried clearing cache, reintalling laravel project and other suggestions on internet but were not useful

1

There are 1 best solutions below

1
Pippo On BEST ANSWER

In Livewire 3 wire:model is deferred by default, try so:

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

model.blur can be a better option:

<input wire:model.blur="name" type="text">