Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

141
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda