2012-01-24 6 views
0

今日のボタンで日付を選択するためにさまざまな「修正」を使用しました。 Firefox上でうまくいけばIEのバグが出てきます。私が今日クリックするたびに、日付が選択され、入力フィールドが更新され、datepickerは閉じられますが、IEは新しいdatepickerを開くまで閉じることができない別のdatepickerを直ちに開きます。私は、日付ピッカーを初期化した直後にJQuery-UIのdatepickerバグが、今日のボタンをハックして日付だけを選択してもIEでのみ表示されます

$j('button.ui-datepicker-current').live('click', function() { 
$j.datepicker._curInst.input.datepicker('setDate', new Date()).datepicker('hide'); 
}); 

この

は修正をDatePickerのコードは、私が

var $j = jQuery.noConflict();    
      $j('#data1, #data2').datepicker({ dayNames: ['Duminica', 'Luni', 'Marti', 'Miercuri', 'Joi', 'Vineri', 'Sambata'], dayNamesMin: ['Du', 'Lu', 'Ma', 'Mi', 'Jo', 'Vi', 'Sa'], firstDay: 1, 
       monthNames: ['Ianuarie','Februarie','Martie','Aprilie','Mai','Iunie','Iulie','August','Septembrie','Octombrie','Noiembrie','Decembrie'], 
       monthNamesShort: ['Ian','Feb','Mar','Apr','Mai','Iun','Iul','Aug','Sep','Oct','Noi','Dec'], 
       showOtherMonths: true, 
       selectOtherMonths: true,    
       dateFormat: 'yy-mm-dd', 
       defaultDate: new Date(), 
       changeMonth: true, 
       showButtonPanel: true, currentText: 'Astazi', 
       changeYear: true  
      }); 

私が使用した最初の修正を使用しています。

var _gotoToday = jQuery.datepicker._gotoToday; 
// datepicker is directly inside the jQuery object, so override that 
jQuery.datepicker._gotoToday = function(a){ 
var target = jQuery(a); 
var inst = this._getInst(target[0]); 
// call the old function, so default behaviour is kept 
_gotoToday.call(this, a); 
// now do an additional call to _selectDate which will set the date and close 
// close the datepicker (if it is not inline) 
jQuery.datepicker._selectDate(a, 
jQuery.datepicker._formatDate(inst,inst.selectedDay, inst.selectedMonth, inst.selectedYear)); 
} 

はまた、ちょうどそれらのすべては、あなたがFirefoxで期待を正確に何をした_gotoToday機能

の終わりに

this._setDateDatepicker(target, new Date()); 
this._selectDate(id, this._getDateDatepicker(target)); 

を追加しようとしたと

はまた、関数を書き直しIEで使用したときに私が上記の問題を残しました。私にとって

答えて

2

が、これはIEにも、働く:

jQuery.datepicker._gotoToday = function(id) { 
    var today = new Date(); 
    var dateRef = jQuery("<td><a>" + today.getDate() + "</a></td>"); 
    this._selectDay(id, today.getMonth(), today.getFullYear(), dateRef); 
}; 
関連する問題