diff options
author | Keith Wood <kbwood.au@gmail.com> | 2009-04-16 10:42:04 +0000 |
---|---|---|
committer | Keith Wood <kbwood.au@gmail.com> | 2009-04-16 10:42:04 +0000 |
commit | 8f503d8d3158a6bca89d52cd460aadafafd234f5 (patch) | |
tree | ee0d5784a7893a3a3eaf8f1c5559fec16ad3acad /ui | |
parent | 62f11b4a2ee8a8c10c51d614e37af1f0216385db (diff) | |
download | jquery-ui-8f503d8d3158a6bca89d52cd460aadafafd234f5.tar.gz jquery-ui-8f503d8d3158a6bca89d52cd460aadafafd234f5.zip |
Datepicker: Fixed #3861 Manually entered date does not update altField
Diffstat (limited to 'ui')
-rw-r--r-- | ui/ui.datepicker.js | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/ui/ui.datepicker.js b/ui/ui.datepicker.js index 3e01a6ae0..b6178d703 100644 --- a/ui/ui.datepicker.js +++ b/ui/ui.datepicker.js @@ -198,7 +198,8 @@ $.extend(Datepicker.prototype, { return false; }); } - input.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress). + input.addClass(this.markerClassName).keydown(this._doKeyDown). + keypress(this._doKeyPress).keyup(this._doKeyUp). bind("setData.datepicker", function(event, key, value) { inst.settings[key] = value; }).bind("getData.datepicker", function(event, key) { @@ -286,7 +287,8 @@ $.extend(Datepicker.prototype, { $target.removeClass(this.markerClassName). unbind('focus', this._showDatepicker). unbind('keydown', this._doKeyDown). - unbind('keypress', this._doKeyPress); + unbind('keypress', this._doKeyPress). + unbind('keyup', this._doKeyUp); } else if (nodeName == 'div' || nodeName == 'span') $target.removeClass(this.markerClassName).empty(); }, @@ -511,6 +513,27 @@ $.extend(Datepicker.prototype, { } }, + /* Synchronise manual entry and alternate field. */ + _doKeyUp: function(event) { + var inst = $.datepicker._getInst(event.target); + if (!$.datepicker._get(inst, 'altField')) + return true; + try { + var date = $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'), + (inst.input ? inst.input.val() : null), + $.datepicker._getFormatConfig(inst)); + if (date) { // only if valid + $.datepicker._setDateFromField(inst); + $.datepicker._updateAlternate(inst); + $.datepicker._updateDatepicker(inst); + } + } + catch (event) { + $.datepicker.log(event); + } + return true; + }, + /* Pop-up the date picker for a given input field. @param input element - the input field attached to the date picker or event - if triggered by focus */ |