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

查看:45
本文介绍了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 日期选择器中阻止的日期的 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天全站免登陆