Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

190
Visualizações
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 ?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda