我想修改 JavaScript(无 JQuery)Pikaday日期选择器以在日历上方的标题区域中显示所选日期。
为此,我创建了一个新函数来呈现标题区域 HTML:
renderHeading = function(instance, c, year, month, days)
{
var opts = instance._o;
var html = '<div class="pika-heading">';
html += '<h3 class="pika-heading-year">' + year + '</h3>';
html += '<h1 class="pika-heading-date">' + opts.i18n.weekdaysShort[day] + ', ' + opts.i18n.monthsShort[month] + '</h1>';
return html += '</div>';
},
这很好用 - 它显示月份和年份。
但是,我无法弄清楚如何让它显示选定的日期。我的目标是让它显示类似“2016 年 12 月 1 日星期一”的内容,但我无法显示“星期一”和“1”。
我能做的最好的就是创建:
window.setDateProperty = this._o.field.value;
在 getDate 函数中并在我的 HTML 渲染函数中返回它,但这仅在单击 2 次后才有效并且看起来很乱。
有人知道将日期字符串返回到插件一部分的正确方法吗?