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

123
Vistas
Datepicker not working on javascript generated html

With jquery, i append some html form inputs to my site on a button click, like these:

html  += '<div class="form-group my-4">';
    html += '<span class="left">Date of ending work <span class="carer_help">Required format: 01-01-2000</span></span>';
    html += '<span class="left"><input class="form-control datepicker" type="text" required="required" name="work_end[' + works_row_melleklet + ']" value="'+work_end+'" /></span>';
html += '</div>';

You can see, that the input have the datepicker class. But my problem is, that the datepicker calendar isnt showing up. I think, because the html input, where i wanna use the calendar, is not in the site's source, its just added by javascript on button click.

How can i fix this?

 $('.datepicker').datepicker({
        format: 'dd-mm-yyyy',
        language: 'en',
        autoclose: true,
        todayHighlight: true
    });
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

When you add dynamic inputs to the DOM, you need to re-initialise with the datepicker method again.

$('body').on('focus',".your_parent_div_name_where_datepicker_is_added", function(){
    $(this).removeClass('hasDatepicker').datepicker();
});​
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