要在 Struts2-jQuery DatePicker 中仅启用一组特定日期(展示中的关闭事件),您需要使用onBeforeShowDayTopics
:
<script>
var availableDates = ["8-12-2014","25-12-2014","26-12-2014"];
$(function(){
$.subscribe('beforeDatepickerShow', function(event, data) {
var date = event.originalEvent.date;
var dmy = date.getDate() + "-"
+ (date.getMonth()+1) + "-"
+ date.getFullYear();
if ($.inArray(dmy, availableDates) != -1) {
event.originalEvent.returnValue = [true, "","Available"];
} else{
event.originalEvent.returnValue = [false,"","unAvailable"];
}
});
<script>
<sj:datepicker onBeforeShowDayTopics = "beforeDatepickerShow"
name = "myDate"
label = "With Close Event" />
注意:这个功能在过去是错误的,所以请确保您没有使用旧版本的插件。
自 3.3.0 以来,它已修复并且工作正常。