gpt4 book ai didi

javascript - <富 :calendar> client side disable weekends

转载 作者:行者123 更新时间:2023-11-29 17:28:44 26 4
gpt4 key购买 nike

我有以下带有 rich:calendar 的 xhtml 文件,我正试图禁用一些日子 using this example .但是永远不会调用 javascript 函数。我不知道为什么。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html ... >

<f:view locale="en">
<script type="text/javascript">
function isDayEnabled(day){
var date = new Date(day.date);
return (date.getDay() == 6);
}
function getDisabledStyle(day){
if (!isDayEnabled(day)) return 'rich-calendar-boundary-dates disabledDay';
}
</script>

<h:head>
<style type="text/css">
.disabledDay { background-color:gray; }
</style>
</h:head>

<h:body>
<div id="workspace">
<h:form id="form">
<h:outputText value="Datum: " />
<rich:calendar mode="ajax" id="calendar"
isDayEnabled="isDayEnabled();" dayStyleClass="getDisabledStyle();">
</rich:calendar>
....

你能帮帮我吗?

最佳答案

如展示示例所示,您需要指定唯一的函数名称。删除括号。

<rich:calendar mode="ajax" id="calendar"
isDayEnabled="isDayEnabled" dayStyleClass="getDisabledStyle">

或者当您实际上使用 RichFaces 4.0 时,您需要检查 different showcase site .

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<h:outputStylesheet>
.everyThirdDay {
background-color: gray;
}

.weekendBold {
font-weight: bold;
font-style: italic;
}
</h:outputStylesheet>
<h:outputScript>
var curDt = new Date();
function disablementFunction(day){
if (day.isWeekend) return false;
if (curDt==undefined){
curDt = day.date.getDate();
}
if (curDt.getTime() - day.date.getTime() &lt; 0) return true; else return false;
}
function disabledClassesProv(day){
if (curDt.getTime() - day.date.getTime() &gt;= 0) return 'rf-cal-boundary-day';
var res = '';
if (day.isWeekend) res+='weekendBold ';
if (day.day%3==0) res+='everyThirdDay';
return res;
}
</h:outputScript>
<rich:calendar dayDisableFunction="disablementFunction"
dayClassFunction="disabledClassesProv" boundaryDatesMode="scroll" />
</ui:composition>

属性重命名为 dayDisableFunctiondayClassFunction

关于javascript - <富 :calendar> client side disable weekends,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6391749/

26 4 0
文章推荐: java - 需要用 JavaScript 编写的 Java 编辑器
文章推荐: widget - 在表单