I have a livewire filter component which I want to filter results by
- All
- Popular
- Latest etc...
This in turn loads the vuejs infinite scroll.
When the page loads, the default filter which is "all", fetches the records and it displays the results fine. When another option is selected e.g. latest, I would like to reload the vuejs infinite scroll and load the latest data, but I get blank results and I can't reload it.
My filter form
<div>
<button wire:click.prevent="all">Show All</button>
</div>
<div>
<button wire:click.prevent="latest">Latest</button>
</div>
<div>
<button wire:click.prevent="popular">Popular</button>
</div>
I emit an event in livewire to the component that loads the vuejs infinite scroll
public $categories;
public $tags;
public $searchType = 'all';
public $keyword;
public function all()
{
$this->emit('all', 'all');
}
public function latest()
{
$this->emit('latest', 'latest');
}
public function popular()
{
$this->emit('popular', 'popular');
}
Calling the listener in other component
public function all()
{
$this->searchType = 'all';
}
public function popular()
{
$this->searchType = 'popular';
}
public function latest()
{
$this->searchType = 'popular';
}
My component with the infinite scroll
<div>
@livewire('search', [
'searchType' => $searchType
])
<post-view inline-template>
<groups-infinite-scroll
searchtype="{{$searchType}}"></groups-infinite-scroll>
</post-view>
</div>
Is there a way to reload the vuejs compionent without reloading the page
Thanks in advance Danny