jQuery UI日期选择器.禁用日期数组 [英] Jquery UI datepicker. Disable array of Dates

查看:140
本文介绍了jQuery UI日期选择器.禁用日期数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试寻找解决我的Jquery ui datepicker问题的解决方案,但我没有运气.这就是我想要做的...

I have been trying to search for a solution to my Jquery ui datepicker problem and I'm having no luck. Here's what I'm trying to do...

我有一个应用程序,在其中,我正在做一些复杂的PHP,以从jQuery UI Datepicker返回我希望阻止的日期的JSON数组.我要返回此数组:

I have an application where i'm doing some complex PHP to return a JSON array of dates that I want BLOCKED out of the Jquery UI Datepicker. I am returning this array:

["2013-03-14","2013-03-15","2013-03-16"]

有没有一种简单的方法可以简单地说:从日期选择器中屏蔽这些日期?

Is there not a simple way to simply say: block these dates from the datepicker?

我已经阅读了UI文档,但看不到有什么对我有帮助的.有人有什么想法吗?

I've read the UI documentation and I see nothing that helps me. Anyone have any ideas?

推荐答案

您可以使用 beforeShowDay 为此

以下示例禁用了从2013年3月14日到2013年3月16日的日期

The following example disables dates 14 March 2013 thru 16 March 2013

var array = ["2013-03-14","2013-03-15","2013-03-16"]

$('input').datepicker({
    beforeShowDay: function(date){
        var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
        return [ array.indexOf(string) == -1 ]
    }
});

演示:小提琴

这篇关于jQuery UI日期选择器.禁用日期数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆