admin管理员组文章数量:1415111
I am working on Primefaces
in JSF , i am just trying to disable all sundays in calendar,
How can i do it,,
- As i referred sites, i got a point we can achieve it using
beforeShowDay
but i don't know how to use it. Primefaces user guide page 10 explains it, but i don't understand what they trying to say.
<p:calendar value="#{dateBean.date}" beforeShowDay="tuesdaysAndFridaysOnly" /> function tuesdaysAndFridaysDisabled(date) { var day = date.getDay(); return [(day != 2 && day != 5), ''] }
In above code they are calling the function tuesdaysAndFridaysDisabled
from beforeShowDay
but my question is
- They are calling the function name as
tuesdaysAndFridaysOnly
but how it will affect the functiontuesdaysAndFridaysDisabled
And it not working too.. How to achieve it and what is happening there..
I am working on Primefaces
in JSF , i am just trying to disable all sundays in calendar,
How can i do it,,
- As i referred sites, i got a point we can achieve it using
beforeShowDay
but i don't know how to use it. Primefaces user guide page 10 explains it, but i don't understand what they trying to say.
<p:calendar value="#{dateBean.date}" beforeShowDay="tuesdaysAndFridaysOnly" /> function tuesdaysAndFridaysDisabled(date) { var day = date.getDay(); return [(day != 2 && day != 5), ''] }
In above code they are calling the function tuesdaysAndFridaysDisabled
from beforeShowDay
but my question is
- They are calling the function name as
tuesdaysAndFridaysOnly
but how it will affect the functiontuesdaysAndFridaysDisabled
And it not working too.. How to achieve it and what is happening there..
Share Improve this question asked Nov 21, 2013 at 6:40 karkkark 4,8536 gold badges32 silver badges44 bronze badges 1- Does this answer your question? Disable specific dates on p:calendar – Jasper de Vries Commented Mar 2, 2023 at 9:44
1 Answer
Reset to default 4This is an error in the Primefaces documentation. They function tuesdaysAndFridaysDisabled
should be called instead of tuesdaysAndFridaysOnly
, which is a javascript function you can call to customize the date.
So the correct source code would look like
<p:calendar value="#{dateBean.date}" beforeShowDay="tuesdaysAndFridaysDisabled" />
And within the function tuesdaysAndFridaysDisabled
you can do whatever you want with the provided parameter date. In this case the tuesdays (2
) and fridays (5
) are disabled.
function tuesdaysAndFridaysDisabled(date)
{
var day = date.getDay();
return [(day != 2 && day != 5), '']
}
The documentation states:
The function returns an array with two values, first one is flag to indicate if date would be displayed as enabled and second parameter is the optional style class to add to date cell.
As you can see. If the date
is a tuesday or friday, the first parameter in the returned array is false
, which means that these days won't be selected within the p:calendar
.
Update: You can find a similar question here: Disable specific dates on p:calendar.
本文标签: javascriptDisable specific days in pcalendarStack Overflow
版权声明:本文标题:javascript - Disable specific days in p:calendar? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745216276a2648186.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论