'PHP Laravel/Livewire Get data from controller to script JS in the HTML view
In a PHP Laravel project, I have a function showCurve($1, $2) (launched by a click in the page), which put data in a variable of the controller.
@foreach ($CurveLimI2T as $curve => $val)
<li><span class="caret" wire:click="showCurve('{{$val['id']}}', '{{3}}')">{{$val['name']}}`</span>
The controller line of work :
$this->dataListPointsMin = $tabFinal_Min;
With dd(), I can see the data in the variable at this point.
So in the view, I get this variable to make work and load the data to a chart via a script at the end of the page. But the variable was empty and nothing appear ..
<script><?php $dataMin = json_encode($this->dataListPointsMin, JSON_NUMERIC_CHECK);?>
I use the same method an another page and the data are in the $this->myvariable and i can get it and work.
The chart was on the same page than the click function showCurve().
Did I have forget anyhting ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
