Bootstrap show.bs.modal / Datepicker show.bs.modal conflict
See original GitHub issueHi,
I found some weird behaviour when using Datepicker inside a Bootstrap v3 Modal.
I have something like this
$("#my-modal").on("show.bs.modal", function() {
// reset my values
});
$("#my-datepicker").datepicker();
Everytime I click on a datepicker input my “reset my values” code gets executed I found a solution here: http://stackoverflow.com/a/20059099/1909698
Which means my code works after adding:
$("#my-modal").on("show.bs.modal", function() {
// reset my values
});
$("#my-datepicker").datepicker().on('show.bs.modal', function(event) {
// prevent datepicker from firing bootstrap modal "show.bs.modal"
event.stopPropagation();
});
Is it a bug or a feature? 😉
Issue Analytics
- State:
- Created 9 years ago
- Reactions:12
- Comments:27
Top Results From Across the Web
Why does bootstrap-datepicker trigger 'show.bs.modal' when it ...
When I select the input field that contains the date picker, the bootstrap modal event .on('show.bs.modal') gets triggered, which is super ...
Read more >JavaScript · Bootstrap v5.0
Bootstrap provides custom events for most plugins' unique actions. Generally, these come in an infinitive and past participle form - where the infinitive...
Read more >Why is Datepicker not highlighting dates on Bootstrap modal?
The date picker is not highlighting the selected dates on Bootstrap 3 model: modal-datepicker. This is my code: $('#myModal').on('shown.bs.modal', ...
Read more >10 Most Common Bootstrap Mistakes That Developers Make
Bootstrap modal appears under background ... If the modal container or its parent element has a fixed or relative position, the modal will...
Read more >UI page : jquery datepicker not working inside bootstrap modal
I had a datepicker (Jquery UI) inside the Bootstrap modal in a UI page which was working fine till now but since after...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Using
shown
andhidden
events instead ofshow
andhide
is not always possible. A better workaround is to check the event namespace:Just faced with this issue in past a couple of hours. We solved it by using “shown.bs.modal” instead of “show.bs.modal” on modal event.
$(“#my-modal”).on(“shown.bs.modal”, function() { // reset my values });