From 1c769745447daa33baee0014e1373bf063271bc0 Mon Sep 17 00:00:00 2001 From: wzca Date: Sun, 27 Nov 2016 14:48:10 +0800 Subject: [PATCH] Update calendar.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在日历中添加一个回调参数,用户可自行判断是否禁用某此日期。 --- js/calendar.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/js/calendar.js b/js/calendar.js index 82e321f7..0222ff40 100644 --- a/js/calendar.js +++ b/js/calendar.js @@ -59,6 +59,7 @@ onMonthYearChangeStart onMonthYearChangeEnd */ + isValidate: null }; params = params || {}; for (var def in defaults) { @@ -628,7 +629,13 @@ if ((minDate && dayDate < minDate) || (maxDate && dayDate > maxDate)) { addClass += ' picker-calendar-day-disabled'; } - + // isValidate + if (typeof params.isValidate == "function") { + if (!params.isValidate(formatDate(dayDate))) { + addClass += ' picker-calendar-day-disabled'; + } + } + dayDate = new Date(dayDate); var dayYear = dayDate.getFullYear(); var dayMonth = dayDate.getMonth();