Muhammad Umair
Muhammad Umair

Reputation: 19

Laravel 8 Livewire wire:click:prevent Not Working

Please Someone please I am in the middle of my final year project but this is not working I am trying for 3 days I am new so I don't know how to ask a question so if you need something please ask me Thanks This is the view for Shop and i have used Composer require Hardevine/shoppingcart

enter image description here

This is the ShopComponent for Shop

enter image description here

Upvotes: 1

Views: 11648

Answers (6)

Gurpreet Saini
Gurpreet Saini

Reputation: 3

Remove .prevent and add type="button"

Example:

<button type="button"  wire:click="update()" class="btn btn-success btn-block">Update</button>

Upvotes: 0

Moaz Dey alnour
Moaz Dey alnour

Reputation: 1

Your livewire template code should be wrapped inside a single-parent div:

<div>
    <!-- Livewire Component Template-->
</div>

Upvotes: 0

Two
Two

Reputation: 656

My solution was based on @KumTem answer

Inside the livewire blades located at app\resources\views\livewire\sample_blade.php

<div id="main">
... templates here
</div>

Upvotes: 0

KumTem
KumTem

Reputation: 11

I had same problem. To solve this issue what I did was enclose my blade template files with a <div> containing an id="main" like so:

<div id="main">
    your blade template code
<div>

Upvotes: 1

Mazen Al-Zubairi
Mazen Al-Zubairi

Reputation: 11

When I ran Laravel 8 on IIS, I had a similar problem. The problem was that the browser couldn't access some of the livewire js files, and the solution was:

Go to D:\Projects\Laravel\laravel8ecommerce\vendor\livewire\livewire\config\livewire.php and set

'asset_url' => "your_url",

and the problem was disappeared.

Upvotes: 1

Yudiz Solutions
Yudiz Solutions

Reputation: 4449

Instead Of This

wire:click:prevent=“store({{$product->id}},’{{$product->name}}’,{{$product->regular_price}})”

You need to use this in your blade file

@livewireStyles
    your code will be in this area
@livewireScripts

Try This For Calling Store Function

wire:click.prevent="store({{$product->id}},{{$product->name}},{{$product->regular_price}})”

Or

wire:click="store({{$product->id}},{{$product->name}},{{$product->regular_price}})”

Upvotes: 0

Related Questions