diff --git a/js/bootstrap-datepicker.js b/js/bootstrap-datepicker.js index 8b521795c..e083080fa 100644 --- a/js/bootstrap-datepicker.js +++ b/js/bootstrap-datepicker.js @@ -512,6 +512,25 @@ } }, + clearDates: function(){ + var element; + if (this.isInput) { + element = this.element; + } else if (this.component) { + element = this.element.find('input'); + } + + if (element) { + element.val('').change(); + } + + this.update(); + this._trigger('changeDate'); + + if (this.o.autoclose) { + this.hide(); + } + }, setDates: function(){ var args = $.isArray(arguments[0]) ? arguments[0] : arguments; this.update.apply(this, args); @@ -1024,17 +1043,7 @@ this._setDate(date, which); break; case 'clear': - var element; - if (this.isInput) - element = this.element; - else if (this.component) - element = this.element.find('input'); - if (element) - element.val("").change(); - this.update(); - this._trigger('changeDate'); - if (this.o.autoclose) - this.hide(); + this.clearDates(); break; } break;