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

372
Visualizações
How can i activate date, month and year in Air Datepicker (function onRenderCell)

I want to set up a calendar in such a way that it would show the years, months and dates in an array. I think this should work in the onRenderCell function but don't fully understand it.

In AirDatepicker, the days of the month, 12 months and a window of years are drawn separately. The numbers of the month are displayed correctly. Months and years are not displayed.

my html

 <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/air-datepicker/2.2.3/css/datepicker.min.css" rel="stylesheet" type="text/css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/air-datepicker/2.2.3/js/datepicker.min.js"></script>
</head>
<body>
    <input type="text" id="datepicker">
    <script src="main.js"></script>
</body>
</html>

my js

 let days   = [ "2022-4-15", "2022-5-3", "2022-4-1",  "2021-2-20"];

$('#datepicker').datepicker({
    onRenderCell: function (date, cellType) {
        new_date = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();

        //all dates passive
        let disabled = true;

        //if the date is in the array, she becomes active
        if (cellType == 'day'){
             disabled = days.indexOf(new_date) == -1
        }

        //called but not working
        if (cellType == 'month' && disabled == false){
            disabled = days.indexOf(new_date) == -1
        }
        if (cellType == 'year' && disabled == false){
             disabled = days.indexOf(new_date) == -1
        }

        return {disabled: disabled}
    }
});

Tell me what exactly am I doing wrong? How to make it so that when choosing months, those of them that have the desired dates are displayed?

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