for some reason my modal is opened without the grey background although i'm using the same code as in there website : http://angular-ui.github.io/bootstrap/#/modal
the only difference is that i used a template from separated html file and not inside a <script>
tag.
i noticed that its not adding this code: <div class="modal-backdrop fade in"></div>
inside the main modal container <div class="modal fade in">
To show a bootstrap modal inside a div the logic behind the above code is to append the HTML code of the modal as well as the modal-backdrop inside that specific div(blue div whose position is relative) and then making the CSS for modal and modal-backdrop to position:absolute so that the modal and its background gets ...
How do I remove modal overlay? Add data-backdrop="false" option as attribute to the button which opens the modal. Save this answer.
The key idea is to have pointer-events: none; for the body when modal is open. But the specific elements you want to be interacted with should have e.g. pointer-events: auto; . In the example you can click both buttons when dialog is hidden, but only Toggle Dialog button when dialog is shown.
The backdrop option specifies whether the modal should have a dark overlay (the background color of the current page) or not.
The problem is that original backdrop has 0px height, to fix add the following style:
<style>
.modal-backdrop {
height: 100%;
}
</style>
The advantage of this solution over accepted one is that you do not loose dismiss clicking on backdrop.
If you don't like when backdrop dismiss modal add the following to $modal.open:
$modal.open({
...
backdrop: 'static',
...
fixed,
i added windowTemplateUrl
to the $modal.open({..})
options object
which overrides the modal main window : https://github.com/angular-ui/bootstrap/blob/master/template/modal/window.html
so the open code looks like this:
var modalInstance = $modal.open({
templateUrl: 'myModalContent.html',
controller: 'ModalInstanceCtrl',
windowTemplateUrl: 'modalWindowTemplte.html'
...
});
and the override template now forced to included the div.modal-backdrop
<script type="text/ng-template" id="modalWindowTemplte.html">
<div tabindex="-1" role="dialog" class="modal fade" ng-class="{in: animate}" ng-style="{'z-index': 1050 + index*10, display: 'block'}">
<div class="modal-backdrop fade in"></div>
<div class="modal-dialog" ng-class="{'modal-sm': size == 'sm', 'modal-lg': size == 'lg'}"><div class="modal-content" modal-transclude></div></div>
</div>
</script>
add this class to options in open function: 'backdropClass : 'modal-backdrop h-full' like this:
var modalInstance = $modal.open({
templateUrl: 'myModalContent.html',
controller: 'ModalInstanceCtrl',
backdropClass : 'modal-backdrop h-full',
...
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With