我正在尝试编写自定义日期选择器,其中通过
当从自定义下拉菜单中选择月份或年份时,我希望能相应地更改视图中的日期。因此,我从当前月份和年份构建日期字符串(这里新月/年组合的日期默认为1),然后调用...
但是它仍然无法运行。我该如何使其工作?
changeMonth
和changeYear
选项启用的默认月份和年份范围下拉菜单被替换为自定义下拉菜单。就像这样:Fiddle: http://jsfiddle.net/gGV3v/
$("#myId").datepicker({
...default settings...
beforeShow: function() {
...here I replace the default dropdowns by custom dropdowns...
...something like...
$(".ui-datepicker-month").replaceWith("#custom-html-block");
$(".ui-datepicker-year").replaceWith("#another-custom-html-block");
}
});
当从自定义下拉菜单中选择月份或年份时,我希望能相应地更改视图中的日期。因此,我从当前月份和年份构建日期字符串(这里新月/年组合的日期默认为1),然后调用...
$("#custom-html-block .custom-dropdown-option").on("click",function() {
...construct newDateString...
$("#myId").datepicker("setDate",newDateString)
});
$("#another-custom-html-block .custom-dropdown-option").on("click",function() {
...construct newDateString...
$("#myId").datepicker("setDate",newDateString)
});
当通过点击它来编程设置新日期时,我希望具有文本 foo 的 span
保持不变。
问题是:它会清除自定义下拉菜单,然后再次显示默认的下拉菜单。我尝试过像这样的操作:
$("#myId").datepicker($.extend({setDate: newDateString},oldSettings))
但是它仍然无法运行。我该如何使其工作?