0
I need to get the datepicker events added depending on where it is clicked. For example: I need to filter some data per day and I can filter the same data also per month.
But with my code, it’s only working the event of the month because it’s triggered when I click on some day of the following month
$('#calendario').datepicker({
format: "yyyy-mm-dd",
language: "pt-BR",
startDate: '+0d'
}).on('changeDate', function(e) {
let data = e.format(0,"yyyy-mm-dd");
location.href = '/cursos?date=' + data;
})
.on('changeMonth',function(e) {
let obj_mes = e.date;
let mes = obj_mes.toString().split(' ');
let mes_ano = $(".datepicker-switch").html();
let ano = mes_ano.split(' ');
location.href = '/cursos?mes=' + mes[1] + "&ano=" + ano[1];
});
These events will only capture if the user clicks on the datepicker, if he type in the input will not work, I suggest treating everything in "change"
– Caique Romero
But in "change" he misses the event when he changes the year
– Cássio Giehl da Rosa