Open terryaney opened 5 years ago
I suggest to use a data attributes selector that follows Bootstrap's API as data-toggle="datepicker"
.
Usage following @terryaney example:
<div class="form-group">
[...]
<div class="input-group-append">
<button type="button" class="btn btn-secondary" data-toggle="datepicker">
<i class="input-group-text fal fa-calendar-day"></i>
</button>
</div>
</div>
This feature could be included in v2.0 roadmap and start working on it. I can send a PR and help working on v2.0. 🚀
Ups, there was already an issue in 2013 https://github.com/uxsolutions/bootstrap-datepicker/issues/377
Expected behaviour
Want only the input-group-append item to be the popup trigger for the datepicker (specifically one icon in the input-group-append.
Actual behaviour
Both the input-group-append and the input-group-prepend trigger calendar.
Datepicker version used
1.9.
Example code
My markup looks like this:
With the input looking like this:
With the current code
this.component = this.element.hasClass('date') ? this.element.find('.add-on, .input-group-addon, .input-group-append, .input-group-prepend, .btn') : false;
Basically the 'Date Updated' label, 'operator dropdown' and the calendar icon all trigger the calendar to appear.
To fix this, I added a
componentSelector
option with following default:componentSelector: '.add-on, .input-group-addon, .input-group-append, .input-group-prepend, .btn'
Then I updated line 118 (or so) to:
this.component = this.element.hasClass('date') ? this.element.find(options.componentSelector) : false;
Then when I call
.datepicker()
I use the following code.Then only the calendar icon will trigger the click. Am I too much of an edge case, or is it worth adding this feature?