How do I reset the datepicker calendar values?.. The min and max date restrictions?
问题是,当我清除日期时(通过删除文本框值),以前的日期限制仍然适用.
我一直在整理这documentation个,但没有一个是解决方案.我也无法在SO/Google搜索中找到快速修复
http://jsfiddle.net/CoryDanielson/tF5MH/
Solution:
// from & to input textboxes with datepicker enabled
var dates = $("input[id$='dpFrom'], input[id$='dpTo']");
// #clearDates is a button to clear the datepickers
$('#clearDates').on('click', function(){
dates.attr('value', '');
dates.each(function(){
$.datepicker._clearDate(this);
});
});
_.clearDate()是DatePicker对象的私有方法.在jQueryUI的网站上的公共API中找不到它,但它的工作方式很有魅力.