2012-04-05 140 views
0

我正在开发一个搜索引擎,通过旅行提供,并且i0ve有几个字段与开始日期和结束日期,与datepicker里面。 它工作在Internet Explorer 8中无处不在,但良好:它只显示2的第一个日历... IE浏览器给了我在这些线路的警报,但我看不出哪里出了问题:JQuery datepicker问题与IE8

function spCalendar(id, options, from, to) 
{ 
jQuery(document).ready(
    function() { 
    jQuery.extend( 
    options, { 
    onClose: function() { 
     time = jQuery(this).datepicker('getDate'); 
     jQuery('#'+this.get('id').replace('_selector', '')).val(new Date(time  ).valueOf()); 
}  
} 
    ); 
jQuery.extend(options, spCalLang); 
jQuery('#'+id+'_from_selector').datepicker(options); 
if(from > 0) { 
jQuery('#'+id+'_from_selector').datepicker('setDate', new Date(from));  
} 
else { 
jQuery('#'+id+'_from_selector').val(''); 
}  
jQuery('#'+id+'_to_selector').datepicker(options); 
if(to > 0) { 
jQuery('#'+id+'_to_selector').datepicker('setDate', new Date(to));  
} 
else { 
jQuery('#'+id+'_to_selector').val(''); 
    } 
    } 
); 
} 
; 

感谢帮帮我!

here is the page

+1

您能否提供整个脚本的链接? IE8给你什么错误? – rgvcorley 2012-04-05 15:38:45

+0

[这里是脚本](http://www.mawitalia.it/viaggidiatlantide/components/com_sobipro/var/js/2b243ae1f1120a3d557ef0e4f3189a89.js) IE浏览器给我一个未知的函数错误,但在IE9和其他浏览器,它是没问题的 – 2012-04-05 16:00:26

+0

@FrancescoMinoMatrioskaFogli:您是否仍然遇到此问题或者您是否找到解决方案? – pete 2012-06-21 07:26:10

回答

0

尝试

function() { 
     jQuery.extend( 
      options, { 
       onClose: function(dateText, inst) { 
       var dtPicker = $("#"+inst.id); 
        time = dtPicker.datepicker('getDate'); 
        jQuery(jQuery(dtPicker).attr('id').replace('_selector', '')).val(new Date(time).valueOf()); 
       }     
      } 
     ); 

也为IE7 为 'yearSuffix' 删除最后一个逗号: '',< ----

spCalLang = { 
'timeOnlyTitle': 'Choose Time', 
'timeText': 'Time', 
'hourText': 'Hour', 
'minuteText': 'Minute', 
'secondText': 'Second', 
'currentText': 'Oggi', 
'closeText': 'Scegli', 
'monthNames': ['Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre'], 
'monthNamesShort': ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], 
'dayNames': ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], 
'dayNamesShort': ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], 
'dayNamesMin': ['Do', 'Lu', 'Ma', 'Me', 'Gi', 'Ve', 'Sa'], 
'weekHeader': '', 
'yearSuffix': ''}; 
+0

ok!,没有datepicker显示,但它似乎有一些与现在的搜索功能的问题....每个我选择的日期,结果总是每个提供,没有按日期过滤... – 2012-04-07 08:49:43

0

我不知道如果你仍然有这个问题,但我看到你的OP代码中的两个问题已经修复如下:

function spCalendar(id, options, from, to) { 
    jQuery(document).ready(function() { 
     jQuery.extend(options, { 
      "onClose": function() { 
       var time = jQuery(this).datepicker('getDate'); //Added var keyword to declare variable 
       jQuery('#' + this.get('id').replace('_selector', '')).val(new Date(time).valueOf()); 
      } 
     }); 
     jQuery.extend(options, spCalLang); 
     jQuery('#' + id + '_from_selector').datepicker(options); 
     if (from > 0) { 
      jQuery('#' + id + '_from_selector').datepicker('setDate', new Date(from)); 
     } else { 
      jQuery('#' + id + '_from_selector').val(''); 
     } 
     jQuery('#' + id + '_to_selector').datepicker(options); 
     if (to > 0) { 
      jQuery('#' + id + '_to_selector').datepicker('setDate', new Date(to)); 
     } else { 
      jQuery('#' + id + '_to_selector').val(''); 
     } 
    }); 
}​ //removed unnecessary semi-colon 

我不再拥有IE8,所以我无法测试您链接到的网站。此外,链接到http://www.mawitalia.it/viaggidiatlantide/components/com_sobipro/var/js/2b243ae1f1120a3d557ef0e4f3189a89.js返回404 - 未找到。