正如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