【问题标题】:Kevin Luck's JQuery date picker plugin - render calendar in date interval and highlighting custom daysKevin Luck 的 JQuery 日期选择器插件 - 以日期间隔呈现日历并突出显示自定义日期
【发布时间】:2011-10-17 21:23:38
【问题描述】:

我对 Kevin Luck 的 JQuery 日期选择器插件有疑问。

是否可以从 选择的日期(例如从 01/01/1990 到 01/01/2015)? 我想突出显示自定义日期(设置 css 类 .selected)。 例如选择这些天:

1990 年 1 月 6 日 | 1995 年 9 月 2 日 | 2005 年 10 月 3 日 | 2007 年 11 月 1 日 | 2010 年 6 月 7 日 |

我试着写了一些代码来实现这个,但还是不行。

    $(function(){

        var testCallback = function($td,thisDate, year, month,day)
        {
            // some implementation here


            return true;
        }


        $('#calendar')
            .renderCalendar({renderCallback:testCallback})          
            .datePicker(
                {   
                    inline:true,
                    selectMultiple:false,
                    startDate:'01/01/1990'
                })              
            .bind(
            'dateSelected',
            function(e, selectedDate, $td)
            {
                date = selectedDate.asString();

                date = date.split(/\//);

                getStuffByAjax(date[2],date[1],date[0]);
            }
        );

});

function getStuffByAjax(year,month,day){
    // some implementation here

    return true;        
}

如果我使用 renderCallback 函数,我会得到渲染日历 一年中只有一个月。

有什么想法吗?

非常感谢您的帮助。

【问题讨论】:

    标签: jquery jquery-plugins


    【解决方案1】:

    我会回答我的问题。所以我所要做的就是把 renderCallBack 函数 进入 datePicker 方法:

    // JavaScript Document
    
    $(function(){               
            $('#calendar')      
                .datePicker(
                    {   
                        inline:true,
                        selectMultiple:false,
                        startDate:'01/01/1990',
                        renderCallback:function($td, thisDate, month, year)
                        {
    
                            if(thisDate.getDate() == 10){
                                $td.addClass('selected');   
                            }
    
    
    
                        }
                    })              
                .bind(
                'dateSelected',
                function(e, selectedDate, $td)
                {
                    date = selectedDate.asString();
    
                    date = date.split(/\//);
    
                    getStuffByAjax(date[2],date[1],date[0]);
                }
            );
    
    });
    
    function getStuffByAjax(year,month,day){
        // some implementation here
    
        return true;        
    }
    

    现在一切都如我所愿。干杯。

    【讨论】:

      猜你喜欢
      • 2014-12-05
      • 1970-01-01
      • 1970-01-01
      • 2021-07-29
      • 1970-01-01
      • 2015-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多