,因爲它是在幾乎每一個瀏覽器:
產生錯誤我不會使用這種解決方案
$(function() {
$('#datepicker').datepicker({
onSelect: function(dateText, inst) { inst.show() }
});
});
你可以做的最好的事情是覆蓋jQuery的日期選擇器的_selectDate方法。
您再次添加此功能的日期選擇這樣做:
$('#dateField').datepicker({
changeMonth: true,
changeYear: true,
},
$.datepicker._selectDate = function(id, dateStr){
var onSelect,
target = $(id),
inst = this._getInst(target[0]);
dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
if (inst.input) {
inst.input.val(dateStr);
}
this._updateAlternate(inst);
onSelect = this._get(inst, "onSelect");
if (onSelect) {
onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
} else if (inst.input) {
inst.input.trigger("change"); // fire the change event
}
if (inst.inline){
this._updateDatepicker(inst);
} else {
this._lastInput = inst.input[0];
if (typeof(inst.input[0]) !== "object") {
inst.input.focus(); // restore focus
}
this._lastInput = null;
}
})
);
通常會有一個「this._hideDatepicker();」在這個腳本中。 我把它遺漏了。您也可以更改jQuery文件本身,但是我不喜歡做這些事情,因爲在更新jQuery之後您將失去功能。
有了我的解決方案,就沒有必要這樣做了。
謝謝...這一個工作! – VeeBee 2012-01-06 08:02:21
此結果爲'未捕獲的類型錯誤:對象#