简体   繁体   English

在datePicker上选择日期的事件

[英]Event for select a date on datePicker

I need to compare two calendar dates. 我需要比较两个日历日期。 I wrote the javascript function too. 我也写了javascript函数。 But how can I execute this function(which event?) on select a date from the datePicker? 但是,如何在从datePicker中选择一个日期时执行此函数(哪个事件?)? See my JSF code 查看我的JSF代码

<h:outputText value="From Date" />
<p:calendar id="fDate" value="#{backingBean.fDate}" mode="popup"
    showOn="button" pattern="dd/MM/yyyy">

</p:calendar>
<p:message id="fId" for="fDate" />

<h:outputText value="To Date" />
<p:calendar id="tDate" value="#{backingBean.tDate}" mode="popup"
    showOn="button" pattern="dd/MM/yyyy" ondateselected="compareDate();" />
<p:message id="tId" for="tDate" />

ondateselected="compareDate(); is not executing at all, it is wrong ,I guess. I'm using primefaces-3.0.M3 with JSF2. ondateselected="compareDate();根本没有执行,这是错误的,我想我在JSF2中使用primefaces-3.0.M3。

not sure when exactly they changed it to use p:ajax , but maybe it was before 3.0M3 不知道何时将它们更改为使用p:ajax,但是可能是在3.0M3之前

so try this way 所以这样子

<p:calendar value="#{backingBean.tDate}">
    <p:ajax event=”dateSelect” oncomplete="compareDate();return false;" />
</p:calendar>

now when i think about it again i think you can put the js function in onsuccess="" and remove the return false; 现在,当我再次考虑时,我认为您可以将js函数放在onsuccess =“”中,并删除return false;。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM