Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

166
Views
How to refresh livewire component on difference Route or Page?

i have 2 livewire component on difference route :

route : ../find/add

class Preview extends Component
{

    public $rabId;

    public function render()
    {
        $rab = Rab::find($this->rabId);

        return view('livewire.rab.preview', [
            'rab' => $rab,
        ]);
    }


    public function sendFinanceData(int $rabId)
    {
    
        $rab = Rab::find($rabId);

        ModelRabStatus::updateOrCreate([
            'rab_id' => $rabId,
        ], [
            'status' => RabStatus::Pending,
        ]);

        $this->emit('sendRabToFinance');
    }

}

and route : ../fin/list

class Index extends Component
{
    protected $listeners = [
        'sendRabToFinance' => '$refresh',
    ];

    public function render()
    {

        $pending = ModelRabStatus::whereStatus(RabStatus::Pending)->orderBy('created_at', 'asc')->paginate(10);

        $approved = ModelRabStatus::whereStatus(RabStatus::Approved)->orderBy('updated_at', 'desc')->paginate(10);

        return view('livewire.finance.f-rab.index', [
            'pending' => $pending,
            'approved' => $approved,
        ]);
}

}

i want to refresh Index component when i click wire:click="sendFinanceData{{$id}}" but it doesn't work using magic $refresh. Any reference how to refresh the component on a different route or page?

7 months ago ยท Juan Pablo Isaza
Answer question
Find remote jobs