2013-02-24 56 views
0

我的日期选择器下面有一个不错的传说,它工作正常,直到你点击下个月。我添加了链接,因为很难解释,请点击“Prijzen 2013”​​选项卡,然后点击periode toevoegen添加日期选择器。日期选择器显示下面几个月的传奇消失点击下个月

https://www.huurhulp.nl/wijzigen/wijzigen.php?wijzigen_adv=4&code=321fa6715e552e9bd495753f44b04db8

这是做这份工作(在日期选择器beforeshow)功能:

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:&nbsp;&nbsp;</td><td style="background-color:red;width:15px;"></td>' 
    legenda = legenda + '<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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

你为什么不只需插入一个单独的DIV的传奇? – jaudette 2013-02-24 10:17:29

回答

1

根据文档hereonChangeMonthYear函数可能是您需要的。

$('#ui-datepicker-div').datepicker({ 
    ... 
    onChangeMonthYear: function(year, month, inst) { 
    insertMessage(); 
    }, 
    } 
}); 

或类似的东西。它在日期选择器移动到新的月份/年时调用。

+0

不能,Beforeshow只在第一次演出时被调用。测试它与警报.... – 2013-02-24 10:30:24

+0

@JilcoTigchelaar thx,只是更新代码,得到了错误的钩子。 – jaudette 2013-02-24 10:53:48

+0

谢谢,做了这个工作(对于一部分)。我也改变了一下功能: – 2013-02-24 13:51:27

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:&nbsp;&nbsp;</td><td style="background-color:red;width:15px;"></td>'; 
legenda = legenda + '<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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); 
} 

}

相关问题