gpt4 book ai didi

javascript - dojo.ById 不工作

转载 作者:行者123 更新时间:2023-11-28 13:34:27 25 4
gpt4 key购买 nike

我有一个工作正常的日历小部件。我遇到的问题是选择日期时 - 代码找不到我想要设置为所选日期的字段,而且我不明白为什么不这样做。

    <xp:panel id="calendarHolder">
<script>
require([ "dijit/Calendar", "dojo/date", "dojo/domReady!", "dijit/registry" ],
function(Calendar, date){
new Calendar({ value: new Date(),

onValueSelected: function(date){calendarDateClicked(date);
}},"mycal");

//Set month in correct format
function setMonth(month){
switch(month)
{
case 1:
month = "Jan";
break;
case 2:
month = "Feb";
break;
case 3:
month = "Mar";
break;
case 4:
month = "Apr";
break;
case 5:
month = "May";
break;
case 6:
month = "Jun";
break;
case 7:
month = "Jul";
break;
case 8:
month = "Aug";
break;
case 9:
month = "Sep";
break;
case 10:
month = "Oct";
break;
case 11:
month = "Nov";
break;
case 12:
month = "Dec";
break;
}
return month;
}
//create Click action
function calendarDateClicked(date){
var d = new Date(date);

var month = (d.getMonth() + 1);
month = setMonth(month);
var day = '' + d.getDate() + ",";
var year = d.getFullYear();

var dateString = [month,day,year].join(" ");

dojo.byId('#{id:hiddenCalWidgetSelectedDate}').value = dateString

dojo.byId('#{id:calDate}').value = dateString;
XSP.partialRefreshPost("#{id:mainPanel}",{
onComplete: function() {
XSP.partialRefreshGet("#{id:sideViews}", {});
}
});//Post Value to server
}

});
</script>

<div id="mycal">
</div>
<div id="textbox">
<xp:inputText id="hiddenCalWidgetSelectedDate"
style="display:block;" value="#{sessionScope.selectedDate}">
<xp:this.defaultValue><![CDATA[#{javascript://
var d = new Date(/*Today*/);
var month = '' + (d.getMonth() + 1);
var day = '' + d.getDate();
var year = d.getFullYear();

if (month.length < 2) month = '0' + month;
if (day.length < 2) day = '0' + day;

return [day,month,year].join("/"); }]]></xp:this.defaultValue>
</xp:inputText></div>
</xp:panel>

我得到的错误是 dojo.byId('#{id:hiddenCalWidgetSelectedDate}') 为 null

如有任何帮助,我们将不胜感激。

格雷姆

最佳答案

如果您向 XPage 添加普通的脚本 block ,EL 将不会得到解析。

您必须将代码添加到 xp:scriptBlock 中。

关于javascript - dojo.ById 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22538705/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com