1

I need to enable only particular dates in a calendar, disabling all the other dates.

I tried with onCompleteTopics and onBeforeShowDayTopics using Struts2-jQuery DatePicker without success.

With raw jQuery I am able to do it as shown in this Fiddle

I need the same functionality using Struts2-jQuery DatePicker.

4

1 回答 1

2

要在 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 以来,它已修复并且工作正常。

于 2014-12-04T11:14:12.217 回答