Comments (8)
Currently the only way to accomplish this would be to manually disable the backdrop for the desired modals with $(element).modal({ backdrop: false })
or set the attribute data-backdrop="false"
on the element.
I could see having an option in the ModalManager class to do this automatically would be ideal. Is there a specific reason you don't want to fade out the underlying modals as they stack? Just trying to get an idea of the use case.
What would you expect to happen if the user clicks on background modal? If you don't have the backdrop they could possibly interact with other page elements while it is open. Would a backdrop with opacity: 0
be better? This would still allow the modal to disappear if the user clicks on the background.
from bootstrap-modal.
There is now a backdropLimit option in the current wip-2.0 branch that you can use to accomplish this.
from bootstrap-modal.
Thanks! Sorry for not responding, these emails slipped out of my inbox. data-backdrop actually turned out to be a fine solution for our use, the backdropLimit is great as well.
from bootstrap-modal.
No problem! The advantage of using backdropLimit and the main reason why I put it in is because now it doesn't matter which order the modal's appear and I imagine it might be pretty inconvenient to maintain data-backdrop for an application with a lot of modals. It also provides an easy way to stop all backdrops as well by setting it to 0.
Anyways, glad you have been able to find a workable solution in the meantime.
Thanks
from bootstrap-modal.
What's the proper method to implement backdropLimit?
from bootstrap-modal.
There's a few ways you can do it:
- Set it globably
$.fn.modalmanager.defaults.backdropLimit = 1
- Set it on a particular instance
$('body').modalmanager({ backdropLimit: 1 })
- Knowing that one gets created on body by default, use the data api
<body data-backdrop-limit="1">
The trick with 1 and 2 is that you will need to make sure they are run before opening the first modal.
from bootstrap-modal.
Awesome - thanks. I wanted the single backdrop to always be directly behind the topmost modal and above all others so I rigged this up really quick:
$('.modal').on('shown', function() {
var zIndex = $('.modal-scrollable:last').css('z-index') - 5;
$('.modal-backdrop').css('z-index', zIndex);
});
$('.modal').on('hide', function() {
var zIndex = $('.modal-scrollable:last').css('z-index') - 15;
$('.modal-backdrop').css('z-index', zIndex);
});
It's far from perfect but seems to get the job done for now. If you could implement an option like this in later versions that'd be great!
from bootstrap-modal.
Interesting use of the backdropLimit feature. I'll think about how I might easily implement something like this. Currently it would be a little difficult but I'm working on some new features so maybe I'll be able to get something in there.
Thanks
from bootstrap-modal.
Related Issues (20)
- is there any compatibility issues with select2.js? HOT 1
- Construct ajax query (ie. ajax Contact form)
- can i use this without bootstrap HOT 1
- angular 1.2.* ng-include used inside ui-bootstrap - modal opening page scrolls to top
- Show Modal Without overlay.
- Modal opens with a delay compared to standard BS3 modal
- Use modal with form validation
- body class="modal-open" style="padding-right: 15px" HOT 1
- Modal don't scroll when closing top modal
- The bootstrap dependency is different between github repo and bower repo.
- make collapsable?
- event.relatedTarget()
- How to relocate modal inside into a div
- Publish as NPM package
- Incompatible with Boostrap 4? HOT 4
- when using this with bootbox.js ,the bootbox dialog style was confused HOT 9
- Stackable: Close modal when clicked outside
- Will you upgrade to Bootstrap 4? HOT 1
- event listener for complete loading
- Replaced # with javascript:; in this statement and it worked.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bootstrap-modal.