Skip to content

Commit ff49804

Browse files
committed
Add hasInput flag for handling non-input uses
1 parent 7663efd commit ff49804

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

js/bootstrap-datepicker.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
});
4141
this.isInput = this.element.is('input');
4242
this.component = this.element.is('.date') ? this.element.find('.add-on') : false;
43+
this.hasInput = this.component && this.element.find('input').length;
4344
if(this.component && this.component.length === 0)
4445
this.component = false;
4546

@@ -50,7 +51,7 @@
5051
keydown: $.proxy(this.keydown, this)
5152
});
5253
} else {
53-
if (this.component){
54+
if (this.component && this.hasInput){
5455
// For components that are not readonly, allow keyboard nav
5556
this.element.find('input').on({
5657
focus: $.proxy(this.show, this),
@@ -125,7 +126,7 @@
125126
if (e ) {
126127
e.preventDefault();
127128
}
128-
if (!this.isInput) {
129+
if (!this.isInput && this.hasInput) {
129130
$(document).on('mousedown', $.proxy(this.hide, this));
130131
}
131132
this.element.trigger({

0 commit comments

Comments
 (0)