C# jQuery DateTimePicker未显示第一时间字段获取焦点
我开发了一个使用Trent Richardson的jQuery DateTimePicker的web应用程序 (见附件) 这是一个C#aps.net应用程序,它有一个名为tbDate的字段,因为我有一个母版页,这个字段在jQuery中称为#MainContent_tbDate 在后端C#代码中,已将以下行添加到PagePreRenderComplete事件中C# jQuery DateTimePicker未显示第一时间字段获取焦点,c#,jquery,asp.net,jquery-ui,C#,Jquery,Asp.net,Jquery Ui,我开发了一个使用Trent Richardson的jQuery DateTimePicker的web应用程序 (见附件) 这是一个C#aps.net应用程序,它有一个名为tbDate的字段,因为我有一个母版页,这个字段在jQuery中称为#MainContent_tbDate 在后端C#代码中,已将以下行添加到PagePreRenderComplete事件中 tbDate.Attributes.Add("onFocus", "getDate('#MainContent_tbDate');");
tbDate.Attributes.Add("onFocus", "getDate('#MainContent_tbDate');");
如您所见,这只是将onFocus事件添加到字段中。(这适用于其他12个领域)
在我的.js文件中,我有以下代码
//This function launches the date picker
function getDate(field){
if (debug)
{
$.jGrowl("Displaying Date for field " + field);
}
$(field).datetimepicker({
dateFormat:'dd/mm/yy',
timeFormat:'hh:mm'
});
if (debug) {
$.jGrowl("Launched " + field);
}
}
当字段获得焦点时,将运行此操作。现在问题是它第一次得到关注,我看到我的第一条jGrowl消息,然后没有日期选择器,然后我看到我的第二条jGrowl消息
我没有脚本错误
如果我将焦点从字段中移开,然后将其返回,则可以正确地看到日期选择器
为什么我不在第一次聚焦时看到它
谢谢
SM试试这个:
function getDate(field){
$(function(){
if (debug)
{
$.jGrowl("Displaying Date for field " + field);
}
$(field).datetimepicker({
dateFormat:'dd/mm/yy',
timeFormat:'hh:mm'
});
if (debug) {
$.jGrowl("Launched " + field);
}
})
}
这个问题在IE8中得到了解决,但是在Mac和Windows XP上,这个问题仍然出现在Chrome中。