Livewire click event is not working in Laravel 7

Hi,

I am new to livewire.

I installed the package and did the counter example as per the documentation.

I have added the @livewireAssets just above the scripts.The counter.blade.php is like below:

div style="text-align: center">
     </button wire:click="increment">+</button>
     </h1>{{ $count }}</h1>
     </button wire:click="decrement">-</button>
div>

(I intentionally removed< in div command to show html code)
and I added to view the counter as below:
@livewire(‘counter’)

and the Counter.php file as below:

<?php

namespace App\Http\Livewire;

use Livewire\Component;

class Counter extends Component
{

 	public $count = 5;

    public function increment()
    {
        $this->count++;
    }

    public function decrement()
    {
        $this->count--;
    }


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

It shows the initial value. But, when I click on + or - symbol, nothing happening.

Can anyone help me to solve this issue?

Or How can I check the click event is reaching the Counter.php function?

Regards,
Manu

i think livewireAseets is deprecated u should be using this

@livewireStyles
...
@livewireScripts

Hi,

Thanks for your reply. I have tried with your suggestions. But, now I am getting net::ERR_ABORTED 404 (Not Found).

I tried to solve this error by using the command mentioned in the documentation
php artisan vendor:publish --tag=livewire:config

This is also not working. I saw some base URL modification. But how can I modify base URL?

My URL is looks like below:

http://localhost/Projects/testproject

Could you please reply?

I have the same problem

Hey @efmanu, @Jair

first to our question on how to check the click event is correctly fired:

You can always open the Dev Tools and check the Network tab, there you can see whether an ajax request is made on click. In the Request Data you can see the action queue, where you can check which method will be called and also which parameters get passed to it.

Regarding your counter problem:

I’ve created a little Playground for you with an working example. In “livewire.blade.php” you can check the placement and wordings for the livewire blade directives.

I hope this helps!

hey @efmanu, @Jair
See this Video it may helps you with your problem.