0

我正在通过旅行优惠开发一个搜索引擎,并且 i0ve 有几个包含开始日期和结束日期的字段,其中包含 datepicker。它在任何地方都很好用,但在 Internet Explorer 8 中:它只显示 2...IE 的第一个日历在这些行中给我一个警报,但我看不出问题出在哪里:

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( '' );
   }   
  } 
 );
}
;

感谢帮助!

这是页面

4

2 回答 2

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 - Not Found。

于 2012-06-21T07:24:52.130 回答
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': ''};
于 2012-04-05T18:37:38.960 回答