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

215
Vistas
Bootstrap Datepicker get user selected date when it is from saved date (via setDates)

$(function(){

    $( ".cal_date" ).datepicker({
        format: 'yyyy-mm-dd',
        todayHighlight:true,
        viewDate:true,
        multidate: true,

    })
    .on('changeDate', function(e) {
            console.log(e.format());
        }
    )
    $( "#datepicker_12492" ).datepicker('setDates',["2022-03-12","2022-03-15","2022-03-18","2022-03-13","2022-03-31"]);

});
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.standalone.min.css" rel="stylesheet">




<div class="cal_date" id="datepicker_12492"></div>

I have multiple bootstrap datepickers on a page and each one will select multiple dates and save them to database. This works using onchangedata and e.format(). The problem is when the calendar is loaded with the saved dates and you try to unselect a saved one when there are multiple dates. e.format() doesn't return the selected date. In the example, if you select 2022-03-15, it will show 2022-03-31 in the changeDate function.

$( ".cal_date" ).datepicker({
                format: 'yyyy-mm-dd',
                todayHighlight:true,
                viewDate:true,
                multidate: true,

            })
            .on('changeDate', function(e) {
                console.log(e.format());
    });
     $( "#datepicker_userid" ).datepicker('setDates',["2022-03-12","2022-03-15","2022-03-18","2022-03-13","2022-03-31"]);

I am sure it is something easy I am missing, but any help is appreciated.

Thanks!

about 4 years ago · Juan Pablo Isaza
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