GithubHelp home page GithubHelp logo

Comments (8)

jschr avatar jschr commented on July 21, 2024

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.

jschr avatar jschr commented on July 21, 2024

There is now a backdropLimit option in the current wip-2.0 branch that you can use to accomplish this.

from bootstrap-modal.

pristinenoise avatar pristinenoise commented on July 21, 2024

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.

jschr avatar jschr commented on July 21, 2024

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.

caseyjhol avatar caseyjhol commented on July 21, 2024

What's the proper method to implement backdropLimit?

from bootstrap-modal.

jschr avatar jschr commented on July 21, 2024

There's a few ways you can do it:

  1. Set it globably $.fn.modalmanager.defaults.backdropLimit = 1
  2. Set it on a particular instance $('body').modalmanager({ backdropLimit: 1 })
  3. 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.

caseyjhol avatar caseyjhol commented on July 21, 2024

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.

jschr avatar jschr commented on July 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.