Confirm Dialogue closes without input #571

Open
spacebiscuit opened this Issue Jan 3, 2017 · 1 comment

Projects

None yet

2 participants

@spacebiscuit

I followed the simple example for the confirm pop-up. When I listen to a button click the modal appears but the default action isn't prevented so the modal closes without receiving a click.

I can of course fix this by adding the preventDefault but given that this is so fundamental to how the dialogue works I suspect that I have missed something as surely this would be documented in the examples?

@tiesont
Collaborator
tiesont commented Jan 4, 2017

No, Bootbox doesn't attempt to define the behavior of the triggering element, since we can't really know what is triggering a Bootbox modal.

If you look at the source of the examples, you'll see that we cancel the default event for the demo buttons - http://bootboxjs.com/js/demos.js - I could do that because I knew exactly what context Bootbox was being used in and wouldn't be propagating unexpected behavior to other code. The same isn't true for how everyone might use Bootbox, though.

It's worth noting, I suppose, that Bootstrap will automatically cancel the event if you use the data-attribute method of triggering modals with an <a> element (see https://github.com/twbs/bootstrap/blob/v3-dev/js/modal.js) - they don't otherwise.

This won't change in the 4.x branch. It might be worth discussing for the 5.0 version, which is #545 - feel free to make a case for automatically canceling events, if you're so inclined. @tarlepp @makeusabrew ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment