Estoy usando jQuery DateTimePicker . Quiero deshabilitar algunas horas específicas en algunas fechas específicas. Por ejemplo, quiero deshabilitar las 09:00AM a. m. del 29/03/2022 y 10:00AM a. m. del 30/03/2022 .
Ya encontré este código, pero no funciona. El calendario en línea se está ejecutando correctamente.
var specificDates = ['29/03/2022', '30/03/2022']; var hoursToTakeAway = [ [09, 10], [10] ]; onGenerate: function(ct, $i) { var ind = specificDates.indexOf(ct.dateFormat('d/m/Y')); $('.xdsoft_time_variant .xdsoft_time').show(); if (ind !== -1) { $('.xdsoft_time_variant .xdsoft_time').each(function(index) { if (hoursToTakeAway[ind].indexOf(parseInt($(this).text())) !== -1) { $(this).hide(); } }); } }EL CÓDIGO FINAL ESTÁ FUNCIONANDO: (estoy usando momentjs para usar la función de momento en ct)
onGenerate: function(ct,$i) { var ind = specificDates.indexOf(moment(ct).format('DD/MM/YYYY')); $('.xdsoft_time_variant .xdsoft_time').show(); if(ind !== -1) { $('.xdsoft_time_variant .xdsoft_time').each(function(index){ if(hoursToTakeAway[ind].indexOf(parseInt($(this).text())) !== -1) { $(this).addClass('xdsoft_disabled'); } }); } }