1

Je travaille avec http://eonasdan.github.io/bootstrap-datetimepicker/. Je sais que ce n'est plus supporté, mais je travaille aussi avec des rails, et cela rend ma vie tellement plus facile. Ce que j'essaie de faire est de mettre les heures activées à une plage de valeurs. Voici ce que j'ai:enabledHours dans bootstrap-datetimepicker-3

scheduleHandle.onclick = function(){ 
    $('#schedule_date_time_of_class').datetimepicker({ 
     inline: true, 
     sideBySide: true, 
     enabledHours: [[moment().hour(14).minutes(0), moment().hour(17).minutes(0)]] 
    }); 
}; 

est ici l'erreur que je reçois:

Uncaught Tried 24 times to find a valid date 
picker.enabledHours @ bootstrap-datetimepicker.self-9bf8b50ba86095fb5caaadd1ee11eaf661b3f4879f3ea5263d541e9804fd7b15.js?body=1:2188 
(anonymous) @ bootstrap-datetimepicker.self-9bf8b50ba86095fb5caaadd1ee11eaf661b3f4879f3ea5263d541e9804fd7b15.js?body=1:1430 
each @ jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:377 
picker.options @ bootstrap-datetimepicker.self-9bf8b50ba86095fb5caaadd1ee11eaf661b3f4879f3ea5263d541e9804fd7b15.js?body=1:1428 
dateTimePicker @ bootstrap-datetimepicker.self-9bf8b50ba86095fb5caaadd1ee11eaf661b3f4879f3ea5263d541e9804fd7b15.js?body=1:2252 
(anonymous) @ bootstrap-datetimepicker.self-9bf8b50ba86095fb5caaadd1ee11eaf661b3f4879f3ea5263d541e9804fd7b15.js?body=1:2285 
each @ jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:371 
each @ jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:138 
$.fn.datetimepicker @ bootstrap-datetimepicker.self-9bf8b50ba86095fb5caaadd1ee11eaf661b3f4879f3ea5263d541e9804fd7b15.js?body=1:2280 
scheduleHandle.onclick @ 51:150 

Je n'ai pas la moindre idée où je vais mal. Aucune suggestion?

Répondre

0

Vous pouvez passer un tableau d'entiers à enabledHours, en définissant les heures que vous souhaitez désactiver.

Voici un échantillon de travail:

$('#schedule_date_time_of_class').datetimepicker({ 
 
    inline: true, 
 
    sideBySide: true, 
 
    enabledHours: [ 14, 15, 16 ] 
 
});
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet"/> 
 
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.css" rel="stylesheet"/> 
 

 
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js"></script> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.js"></script> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script> 
 

 
<div class="form-group"> 
 
    <div class='input-group date' id='schedule_date_time_of_class'> 
 
    <input type='text' class="form-control" /> 
 
    <span class="input-group-addon"> 
 
     <span class="glyphicon glyphicon-calendar"></span> 
 
    </span> 
 
    </div> 
 
</div>