正如AppSol所指出的那樣,這是jQuery UI和AIR的沙盒問題。但是,製作解決方案非常簡單。只需下載jQuery UI的未縮小版本,並在_updateDatepicker()函數的末尾添加以下內容。在上線16年1月8日的版本8954
$(".ui-datepicker-prev").click(function() {
$.datepicker._curInst.drawMonth--;
if ($.datepicker._curInst.drawMonth < 0) {
$.datepicker._curInst.drawMonth = 11;
$.datepicker._curInst.drawYear--;
}
$.datepicker._updateDatepicker($.datepicker._curInst);
});
$(".ui-datepicker-next").click(function() {
$.datepicker._curInst.drawMonth++;
if ($.datepicker._curInst.drawMonth > 11) {
$.datepicker._curInst.drawMonth = 0;
$.datepicker._curInst.drawYear++;
}
$.datepicker._updateDatepicker($.datepicker._curInst);
});
$(".ui-datepicker-calendar").find("tr > td").each(function() {
$(this).click(function() {
var t = $(this).attr('onclick').split('.')[2].split('(')[1].split(')')[0].split(',');
$.datepicker._selectDay(t[0].substr(1,t[0].length-2),t[1],t[2],this);
});
});
下面是它應該如何看起來像在最後:
/* Generate the date picker content. */
_updateDatepicker: function(inst) {
var self = this;
self.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
var borders = $.datepicker._getBorders(inst.dpDiv);
instActive = inst; // for delegate hover events
inst.dpDiv.empty().append(this._generateHTML(inst));
var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only
if(!!cover.length){ //avoid call to outerXXXX() when not in IE6
cover.css({left: -borders[0], top: -borders[1], width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()})
}
inst.dpDiv.find('.' + this._dayOverClass + ' a').mouseover();
var numMonths = this._getNumberOfMonths(inst);
var cols = numMonths[1];
var width = 17;
inst.dpDiv.removeClass('ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4').width('');
if (cols > 1)
inst.dpDiv.addClass('ui-datepicker-multi-' + cols).css('width', (width * cols) + 'em');
inst.dpDiv[(numMonths[0] != 1 || numMonths[1] != 1 ? 'add' : 'remove') +
'Class']('ui-datepicker-multi');
inst.dpDiv[(this._get(inst, 'isRTL') ? 'add' : 'remove') +
'Class']('ui-datepicker-rtl');
if (inst == $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input &&
// #6694 - don't focus the input if it's already focused
// this breaks the change event in IE
inst.input.is(':visible') && !inst.input.is(':disabled') && inst.input[0] != document.activeElement)
inst.input.focus();
// deffered render of the years select (to avoid flashes on Firefox)
if(inst.yearshtml){
var origyearshtml = inst.yearshtml;
setTimeout(function(){
//assure that inst.yearshtml didn't change.
if(origyearshtml === inst.yearshtml && inst.yearshtml){
inst.dpDiv.find('select.ui-datepicker-year:first').replaceWith(inst.yearshtml);
}
origyearshtml = inst.yearshtml = null;
}, 0);
}
$(".ui-datepicker-prev").click(function() {
$.datepicker._curInst.drawMonth--;
if ($.datepicker._curInst.drawMonth < 0) {
$.datepicker._curInst.drawMonth = 11;
$.datepicker._curInst.drawYear--;
}
$.datepicker._updateDatepicker($.datepicker._curInst);
});
$(".ui-datepicker-next").click(function() {
$.datepicker._curInst.drawMonth++;
if ($.datepicker._curInst.drawMonth > 11) {
$.datepicker._curInst.drawMonth = 0;
$.datepicker._curInst.drawYear++;
}
$.datepicker._updateDatepicker($.datepicker._curInst);
});
$(".ui-datepicker-calendar").find("tr > td").each(function() {
$(this).click(function() {
var t = $(this).attr('onclick').split('.')[2].split('(')[1].split(')')[0].split(',');
$.datepicker._selectDay(t[0].substr(1,t[0].length-2),t[1],t[2],this);
});
});
},
這只是測試了jQuery UI的不過16年8月1日的想法在這個固定未來版本仍然保持不變。您需要將點擊事件處理程序添加到next和prev按鈕以及實際日期。
你錯過了`在腳本上鍵入`-`屬性。其次,你有沒有嘗試隔離錯誤? `$()。ready()`是否工作,乾淨的日期選擇工作,其他插件的工作? – jerone 2011-02-16 07:41:50