我的日期选择器下面有一个漂亮的传奇,它工作正常,直到你下个月点击。我添加了链接因为很难解释,点击“Prijzen 2013”标签,然后点击periode toevoegen添加日期选择器。
https://www.huurhulp.nl/wijzigen/wijzigen.php?wijzigen_adv=4&code=321fa6715e552e9bd495753f44b04db8
这是完成工作的功能(在datepicker中显示之前):
function insertMessage() {
var legenda = '<div class="legenda"><table cellpadding="0" cellspacing="0" style="font-size:11px;color:silver;"><tr><td>Let op! Overlap in afwijkende prijzen is niet mogelijk.</td><td>Gesloten: </td><td style="background-color:red;width:15px;"></td>'
legenda = legenda + '<td> Afwijkende prijs:</td><td style="background-color:#00A800;width:15px;"></td></tr></table></div>';
clearTimeout(insertMessage.timer);
if ($('#ui-datepicker-div .ui-datepicker-calendar').is(':visible')){
$('#ui-datepicker-div').append(legenda);
}
else {
insertMessage.timer = setTimeout(insertMessage, 10);
}
}
我尝试了这个,但不起作用:
$('#ui-datepicker-div').delegate('.ui-datepicker-prev, .ui-datepicker-next', 'click', insertMessage);
答案 0 :(得分:2)
function insertMessage(next) {
var legenda = '<div class="legenda"><table cellpadding="0" cellspacing="0" style="font-size:11px;color:silver;"><tr><td>Let op! Overlap in afwijkende prijzen is niet mogelijk.</td><td>Gesloten: </td><td style="background-color:red;width:15px;"></td>';
legenda = legenda + '<td> Afwijkende prijs:</td><td style="background-color:#00A800;width:15px;"></td></tr></table></div>';
clearTimeout(insertMessage.timer);
if ($('#ui-datepicker-div .ui-datepicker-calendar').is(':visible')){
if (next == 1){
insertMessage.timer = setTimeout(insertMessage, 10);
}
$('#ui-datepicker-div').append(legenda);
}
else {
insertMessage.timer = setTimeout(insertMessage, 10);
}
}
答案 1 :(得分:1)
根据文档here,onChangeMonthYear
函数可能就是您所需要的。
$('#ui-datepicker-div').datepicker({
...
onChangeMonthYear: function( year, month, inst ) {
insertMessage();
},
}
});
或类似的东西。当datepicker移动到新的月/年时调用它。