When I try to toggle a bolean in Livewire/Laravel it always resets back to default value

18 Views Asked by At

I am building a datatable which is to be sortable. When a user clicks the same row, it should switch between being sorted ascending and sending. For some reason, my sortable method always evaluates to false and does not toggle. I am not sure what. Here is my code which is called on click.

public $sortCol = 'next_step_due';
public $sortAsc = true;

public function sortBy($column){

    if ($this->sortCol === $column) {
       $this->sortAsc = !$this->sortAsc;
    }

    dd($column, $this->sortAsc);
}

I have tried rebuilding this, and changing properties to private (docs say not to do this).

I've tried using a ternary operator.

0

There are 0 best solutions below