FilamentF
Filament14mo ago
Venky

Table reload in custom livewire tab by updating in another tab table record.

I have a resource page with Tab implementation. First tab for draft items loaded through livewire page. The second tab is with published items. I wants to refresh the second table when ever I am publishing a record in First tab. Below is the main page
public function getTabs(): array
    {return [
       'All' => Tab::make('All')->schema([
       Livewire::make(ActiveListingTable::class)->key('active-listing-table')
       ]),
       ];
    }
    public function infolist(Infolist $infolist): Infolist
    {return $infolist
     ->schema([
     Tabs::make('Tabs')->contained(false)
     ->tabs([
        Tabs\Tab::make('Draft')
                            ->schema([
                                Livewire::make(DraftListingTable::class)->key('dradt-listing-table')->lazy()
                            ])->extraAttributes([
                                'x-data' => '{ isActive: false }',
                                'x-init' => 'isActive = ($el.closest("[role=\'tablist\']").querySelector("[aria-selected=\'true\']") === $el)',
                                'x-effect' => 'if(isActive) { window.Livewire.emit(\'refreshDraftTable\') }',
                                'x-on:click' => 'isActive = true',
                            ]),
                        Tabs\Tab::make('active-tasks')->label('Published')
                            ->schema([
                                Livewire::make(ActiveListingTable::class)->key('active-listing-table')->lazy()
                            ])->extraAttributes([
                                'x-data' => '{ isActive: false }',
                                'x-init' => 'isActive = ($el.closest("[role=\'tablist\']").querySelector("[aria-selected=\'true\']") === $el)',
                                'x-effect' => 'if(isActive) { window.Livewire.emit(\'refreshActiveTable\') }',
                                'x-on:click' => 'isActive = true',
                            ]),
    ]),
    ]);
    }
Was this page helpful?