0

就像标题说的那样,出于美观的目的,我想将标题(上一个、下一个、当前月份)移到底部。我是个笨蛋,有办法在设置中设置它,还是我必须用 hacky 绝对定位来做到这一点?

4

3 回答 3

2

没有内置的方法可以做到这一点。使用该beforeShow选项将不起作用,因为当它触发日期选择器的 HTML 时,尚未创建。datepicker 小部件应该触发一个create事件,但不会(它在事件文档中被标记为一个错误 - http://jqueryui.com/demos/datepicker/)。

就我个人而言,我认为最干净的方法是focus通过input[type=text]. 不一定是理想的,但这不会让人觉得太hacky并且有效。

$('input')
    .datepicker()
    .on('focus', function() {
        $('.ui-datepicker-header').insertAfter('.ui-datepicker-calendar');
    });

现场示例- http://jsfiddle.net/5gWrS/

于 2012-05-22T16:45:57.003 回答
0

There is the list of all the options for the jqueryui datepicker on the bottom of this page:

http://jqueryui.com/demos/datepicker/

I can not find any option for moving the header.

I think you will have to go with hacky code.

A short code similar to the one below should move the datepicker header at the end of it's parent element, so it should be displayed below the calendar. You should execute the code while opening the datepicker overlay:

jQuery('.ui-datepicker-header').each(function() { $(this).parent().append($(this)) })
于 2012-05-22T15:18:45.463 回答
0

在我的头顶上有几种方法可以做到这一点:

  • 扩展 datepicker 类并添加您自己的 HTML

  • 使用该beforeShow选项更改 DOM。删除标题并将其附加到选择器的底部。

祝你好运

于 2012-05-22T15:17:07.070 回答