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

132
Vistas
How to re-initiate tailwind's datepicker when added dynamically?

I am using tailwind's datepicker and I add new items by clicking a button:

<html>
   <head>
      <!-- ... -->
      <script src="https://unpkg.com/flowbite@1.5.1/dist/datepicker.js"></script>
   </head>
   <body>
      <!-- ... -->
        <input datepicker type="text" placeholder="Select date">
        <button>Add</button>
      <!-- ... -->
      <script>
        document.querySelector('button').addEventListener('click', function() {
          var input = document.createElement('input');
          input.setAttribute('datepicker', '');
          document.body.appendChild(input);

          document.querySelectorAll('[datepicker]').forEach(function(datepickerEl) {
             new Datepicker(datepickerEl, getDatepickerOptions(datepickerEl));
            // ❌ Unhandled Promise Rejection: ReferenceError: Can't find variable: Datepicker
          });
        });
      </script>
   </body>
</html>

Once a new item has been added, it does not have the datepicker. How can I re-initate the datepicker to all new items?

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