Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

successdav's avatar

Livewire wire:click, wire:model not working

I am using laravel 6

I am following the video instructions on Building Data Tables with lifewire I have installed livewire and created a component which creates a controller and a blade page

now this commands: wire:model, wire:click are not working.

Livewire controller

<?php

namespace App\Http\Livewire;

use App\Post;
use Livewire\Component;

class PostsPage extends Component
{
    public $search = 'Jerad Schmidt';

    public function render()
    {
        return view('livewire.posts-page', [
            'posts' => Post::where(
                'title', 'LIKE', '%' . $this->search . '%'
            )->orWhere(
                'body', 'LIKE', '%' . request('search') . '%'
            )->get()
        ]);
    }
}

Livewire Blade page

<div>
    <div>
        <h2 class="is-size-3 has-text-centered mb-small">Latest Info </h2>
        <div style="padding: .2em 1em;">
            <input wire:model="search" class="input mb-medium" type="text" placeholder="Search through posts">
        </div>
        @foreach ($posts as $post)
            @include('sections/partials/_post')
        @endforeach
        
    </div>
</div>

where I include livewire

<div class="container">
    <div class="mt-medium">
        <div class="columns">
            <div class="column is-three-quarters">
                @livewire('posts-page')
            </div>
            <div class="column">
                Hello world from the other side of the country 
            </div>
        </div>
    </div>
</div>
0 likes
33 replies
successdav's avatar

I have it in place on the app.blade.php file but its still not working

successdav's avatar

Nope its not working, I accidentally click the best answer button

bugsysha's avatar

Now I'm under pressure to give best answer to remedy this 🤦🏻‍♂️

1 like
successdav's avatar

yes, I have vue rendering the slider on the page

bugsysha's avatar

I do not see wire:click in code you've presented us with.

bugsysha's avatar

yes, I have vue rendering the slider on the page

When Livewire is crawling the DOM, if it encounters a Vue component, it will skip it's contents.

successdav's avatar

I did the click test which did not work before proceeding to using the wire:model to bind a search input

Nakov's avatar

@successdav but do the posts appear on the page? So when you try to search there is no effect? That's what you are saying?

successdav's avatar

Yep the post appears on the page but when I search no response and when I earlier tried wire:click no response either

bugsysha's avatar

Have you tried to add live after the model?

<input wire:model.live="search"
Nakov's avatar

@successdav maybe your problem is here:

'posts' => Post::where(
                'title', 'LIKE', '%' . $this->search . '%'
            )->orWhere(
                'body', 'LIKE', '%' . request('search') . '%'
            )->get()

You are using the request() on one, use $this->search on both..

Or try

dd($this->search);

within the render function to make sure that there is a request made. Open your Network tab in the browser and check..

bugsysha's avatar

I think he is using request('search') for initial search on the page? But it is strange that he is checking title for one and body for other.

successdav's avatar

no luck

return view('livewire.posts-page', [
            'posts' => Post::where(
                'title', 'LIKE', '%' . $this->search . '%'
            )->orWhere(
                'body', 'LIKE', '%' . $this->search . '%'
            )->get()
        ]);

and on the network no request is made when I type on the search input field

Nakov's avatar

@successdav no errors in the console? I would comment out the Vue component. And make sure that livewire assets are loaded, you can inspect that in your network tab, or in the elements.

successdav's avatar
successdav
OP
Best Answer
Level 4

@nakov @bugsysha After a a whole day struggle I actually got this to work, the problem was with this keyword defer on my app.blade.php

<script src="{{ asset('js/app.js') }}" defer></script>

I dont know what the keyword does but when I remove the keyword "defer" everything now works fine

Thanks all for your effort in assisting me debug this issue

2 likes
haimi's avatar

Ohh My God Unbelievable... This is working fine 100% for me

Nakov's avatar

@successdav Glad you got it working. But I don't know why you didn't get any errors when this did not worked..

Just FYI:

Basically, defer tells the browser to wait "until it's ready" before executing the javascript in that script block.

1 like
successdav's avatar

So now that I had removed this keyword, will that affect performance

Please or to participate in this conversation.