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

304
Visualizações
alpine component fails to execute on livewire update

I have an alpine.js component with livewire data save. https://github.com/TerrePorter/CustomCountrySelectBox.git

I am trying to load two and eventually three of these in sequence on the page. First, the country then when that is selected, I update the state/region, and finally when that is updated I update the city.

The problem is when I update the state/region the alpine.js code does not execute when livewire refreshed that part of the page.

I also tried to make it work all on one page, a select box that updates the next select box, but it would always fail to load the second array.

Here is the relevant part of the template

<div class="p-6">
    <lable>Please select your location: </lable>
    @if ($country == '')
        @component('components.country-select-box', ['countryJson' => $countryJson])@endcomponent
    @endif
    @if ($stateJson != '')
        @component('components.state-select-box', ['stateJson' => $stateJson])@endcomponent
    @endif
</div>

Here is part of the livewire code where I update the state's JSON file.

   public function updatedCountry() {
        $this->stateJson = $this->getStateJson();
    }

   public function getStateJson() {

        $r = Countries::where('short_name', '=', $this->country)->with('states')->first();

        $ret = [];
        foreach ($r->states as $index => $item) {
            $ret[] = ['title' => $item->state_name, 'value' => $item->id];
        }

        return json_encode($ret);
    }

And finally as mentioned before this is the select box dropdown I am using, https://github.com/TerrePorter/CustomCountrySelectBox.git

about 4 years ago · Santiago Trujillo
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