Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

161
Vistas
el cambio a una variable php en blade laravel no persiste

Cuando incremento currentIndex cada vez que hago clic en el botón siguiente, el valor de currentIndex vuelve a su valor predeterminado, que es 1 aquí. Entonces, la actualización de currentIndex no persiste. ¿Alguien tiene alguna idea de por qué? y como puedo solucionar este problema?

 let inputBoxNum = 3 let currentIndex {{ $currentIndex = 1 }} updateButtons() $('.back-btn, .next-btn').on('click', function (e) { console.log({{$currentIndex}}) // returns 1 even if this function was called before let btnClicked = e.target.className.includes('next-btn') ? 'next' : 'back' if (btnClicked === 'next') { {{$currentIndex += 1}} // it increments to 2 console.log({{$currentIndex}}) // returns 2 $('#create-input-box').html(`@include('reservations.create-input-box-'.$currentIndex)`) } else { $('#create-input-box').html(`@include('reservations.create-input-box-'.$currentIndex)`) } updateButtons() }) function updateButtons() { getCurrentIndex() if (currentIndex <= 1) { $('.back-btn').hide() $('.next-btn').show() } else if (currentIndex > 1 && currentIndex < inputBoxNum) { $('.back-btn').show() $('.next-btn').show() } else { $('.back-btn').show() $('.next-btn').hide() } } function getCurrentIndex() { currentIndex = parseInt($('#create-input-box')[0].children[0].className.split("-")[3]) }
about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda