Reputation: 86865
I'm triggering the following modal dialog from javascript:
$('#myModal').modal({
show: true,
backdrop: false
});
Result: the dialog shows up, but is not closed if I click outside of the popup.
When I set backdrop: true
, the dialog is closed on outside click, but the full screen appears with a dimmed overlay.
How can I have a modal popup that does not change the opacity
overlay, but still closes on outside click?
Upvotes: 1
Views: 349
Reputation: 16989
You could add a background-color
to .modal-backdrop
as such...
<style>
.modal-backdrop {
background-color: transparent;
}
</style>
<!-- [...] -->
<script>
// [...]
$('#myModal').modal({
show: true
});
</script>
Plunker link - demo
Upvotes: 1
Reputation: 163
You can leave backdrop:false, and add your own click event to the page:
$('body').click(function(e){
if ($('#myModal').is(e.target))
$('#myModal').modal('hide') //or whatever your bootstrap uses to hide a modal
})
Upvotes: 0