我拼命尝试使用此功能在我的日期选择器中仅启用特定日期,但该beforeShowDay
功能从未被触发:(
即使这不起作用:
$(document).ready(function(){
/*initialisation des composants*/
initComponent();
});
availableDates = new Array();
/* Fonction d'initialisation des composants */
function initComponent(){
/* Date retrait */
$("#dateRetrait").datepicker();
$("#dateRetrait").datepicker({beforeShowDay: function(d) {
console.log("bsd");
alert("bsd");
}});
//$("#dateRetrait").datepicker({buttonImage: "../../../Images/boutons/btn_calendier.png"});
//$("#dateRetrait").datepicker({showButtonPanel: true });
//$("#dateRetrait").datepicker({beforeShow: function() {setTimeout(function() {$(".ui-datepicker").css("z-index", 9999999999);}, 10);}});
$('#comboLieux').attr('disabled', 'disabled');
$('#comboCreneau').attr('disabled', 'disabled');
$('#dateRetrait').attr('disabled', 'disabled');
$('#dateRetrait').datepicker('option', 'minDate', new Date());
$("#dateRetrait").datepicker("option","dateFormat", 'dd-mm-yy');
}
如果您有任何想法,我将不胜感激!
事实上,即使这样也行不通:
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Datepicker - Restrict date range</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function() {
$( "#datepicker" ).datepicker({ minDate: -20, maxDate: "+1M +10D" });
$( "#datepicker" ).datepicker({beforeShowDay: function(d) {
console.log(d);
alert(d);
}});
});
</script>
</head>
<body>
<p>Date: <input type="text" id="datepicker" /></p>
</body>
</html>