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

325
Vistas
How to reload a JavaScript of a page without reloading the page (Vanilla JS)

I have nested fields that are being appended to the DOM when a user wants to add more fields. this is being done by a nested_fields.js file.

The issue is one of the fields being appended is a calender field that is being handled by another JS file called calender_manager.js

calender_manager.js is using the Flatpickr module and it looks for input tags with the .flatpickr class in the HTML file of the page. This happens when the page is loaded so the fields appended to the DOM by nested_fields.js with the .flatpickr class don't get picked up by calender_manager.js.

So far my solution is to make one custom JS file for the nested calendar fields that handles appending the nested fields and adding flatpickr. I was wondering if there is a better way.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I've never heard of flatpickr but I just looked into it, maybe I don't know what you are asking, but are you trying to get it to enable after the page loads? If so calling flatpickr(".my_input"); again works.

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>

<input type="text" class="my_input" /><br />
<input type="button" id="enable" value="Click to enable flatpickr" />
<input type="button" id="disable" value="Click to disable flatpickr" />

<script>
var f;
document.querySelector("#enable").onclick = function () {
    f = flatpickr(".my_input");
}
document.querySelector("#disable").onclick = function () {
    f.destroy();
}
</script>
about 4 years ago · Juan Pablo Isaza Denunciar
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