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

142
Vistas
Clearing value of bootstrap datepicker with viewmode years or months

When I open a bootstrap modal I get the data of previous months or years I tried to filter some data with, with this data some months or years are already selected in my datepicker. When I want to add some more months or years to the datepicker it adds the selected months or years in the textfield of the datepicker.

This also happens when I select the previously selected month or year, I would like to prevent this from happening, so I set the immediateUpdates option to true when I initialize the datepicker. This fixed my problem mentioned above, but now a new problem arises.

When I open the datepicker and select a month or year it now clears my previous values but I'm unable to select new months or years in the selectpicker when I click on them. They are only selectable through the arrow keys and enter key on my keyboard, this won't do and I'm kinda runnning out of ideas on how to fix this.

Beneath this is my HTML and JS code I use to create the datepicker.

HTML:

<input type="text" class="form-control" name="selected_years[]" placeholder="select years" id="years_datepicker" autocomplete="off"/> 
<input type="text" class="form-control" name="selected_months[]" placeholder="select months" id="month_datepicker" autocomplete="off"/>

JS:

function initDatePicker(datePicker, format) {
    let DatePicker = $(datePicker);

    let datepickerFormat = "";
    let datepickerView = "";

    if (format === "yearPicker") {
        datepickerFormat = "yyyy";
        datepickerView = "years";
    } else if (format === "monthPicker") {
        datepickerFormat = "mm-yyyy";
        datepickerView = "months";
    }

    DatePicker.datepicker({
        language: local_language,
        format: datepickerFormat,
        startView: datepickerView,
        minViewMode: datepickerView,
        maxViewMode: datepickerView,
        multidate: true,
        multidateSeparator: ", ",
        todayHighlight: true,
        startDate: start_of_reports,
        endDate: end_of_reports,
        disableTouchKeyboard: true,
        immediateUpdates: true
    });
}
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