Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modal z-index issue. Potential Solution. #3217

Closed
pmsaue0 opened this issue Apr 24, 2012 · 27 comments
Closed

Modal z-index issue. Potential Solution. #3217

pmsaue0 opened this issue Apr 24, 2012 · 27 comments
Labels

Comments

@pmsaue0
Copy link

pmsaue0 commented Apr 24, 2012

I first experienced the modal content displaying beneath the .modal-backdrop scrim in IE7, but I have since seen weird behavior in Chrome.

The problem, in essence, is that .modal and .modal-backdrop are not always siblings with similar attributes. In a recent project I had a deeply nested .modal and there were custom z-indexings elsewhere on the page. Thus, incorrect z-indexing.

I've created a jsFiddle: http://jsfiddle.net/ATeaH/8/ to illustrate the busted and fixed behavior.

Hope this is useful.

@BlackjacketMack
Copy link

Fantastic! Thanks so much for posting a solution.

@jasonmadigan
Copy link

Have been bitten by this today. Thanks for the explanation!

@Szeremeta
Copy link

Many thanks, got caught out by this one too!

@wyaeld
Copy link

wyaeld commented May 30, 2012

gracias, left me extremely confused when this happened to me

@demike
Copy link

demike commented May 30, 2012

Another solution could be to use InsertAfter to insert the backdrop after the modal.
see: http://jsfiddle.net/ByFvY/14/

This has the positive side effect that the modal doesn't need to be moved out of place +
nesting of modals would be possible

note: the InsertAfter should be done in the plugin.

@tompi
Copy link

tompi commented Jun 4, 2012

Thanks a lot! The insertAfter seems to fix it for me.
Modified the Modal.backdrop function(line 803/804 in 2.0.4)

  this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
    .insertAfter(this.$element)

@mauricioquiros
Copy link

Thanks a lot! The insertAfter works for me as in @tompi code.

@mpschr
Copy link

mpschr commented Jun 17, 2012

Perfect, thanks a lot for resolving this!

@edizaziz-dev
Copy link

Thank you Thank you Thank you!

@jdev-d
Copy link

jdev-d commented Jun 28, 2012

Hello guys, I am having the same issue. I already put the piece of script but its still not working for me. I hope you could help. Thanks in advance.

IE 7 problem here: http://www.theeap.com/online-training-tools/online-test.html

@nfang
Copy link

nfang commented Jun 29, 2012

Thanks for the explanation and solution. Works like a charm :)

@lookfirst
Copy link
Contributor

@tompi 's fix works. This should get committed asap.

@sterlingstokes
Copy link

You saved my bum with this. Thank you!

@silviomoreto
Copy link

Thank you! You saved my day too!

@asavin
Copy link

asavin commented Nov 14, 2012

Thanks, that helped me too! This issue was reproducible in all browsers, .NET project.

@kerwitz
Copy link

kerwitz commented Dec 9, 2012

Thanks a lot, the .insertAfter fixed it right away.

@pixelnourish
Copy link

Yep, also hit by this bug, and this fiddle fixed it for me too. Thank you for your time (so long ago!).

@fat
Copy link
Member

fat commented Dec 20, 2012

We explicitly don't want to move the element around the dom. The solution is really don't nest your modals in your dom.

Just put them at the bottom of the body when you write your markup.

@fat fat closed this as completed Dec 20, 2012
@lookfirst
Copy link
Contributor

It isn't always possible to control where the modals are placed in the DOM so blanket statements like that are kind of short sighted. For example, I have a template system that uses russian doll style of generation. A request for a page first renders the innermost template and then cascades upwards from there by rendering the next template and placing the first template within the body of the next template. If the modal is output by the innermost template, it is very difficult to put it at the bottom of the body. Of course, it can be argued that things should be rendered a different way, but the point here is to just say that it isn't always possible to do what you are suggesting.

@kand
Copy link

kand commented Mar 7, 2013

Yea, why is this issue closed? This is still a problem. It's not always possible to put modals at the body level.

@s-anes
Copy link

s-anes commented Apr 26, 2013

Really useful! Thanks!

@Wilsonilo
Copy link

Thanks a lot!

@dip7ul
Copy link

dip7ul commented May 24, 2013

Really useful work on mobile safari ipad

@Gajjar
Copy link

Gajjar commented Jun 19, 2013

Thanks a lot dude, working just fine...!!!!

@naelshawwa
Copy link

Why was this issue closed? As some previous posters have indicated it is not always easy to avoid nesting the modal within DOM especially when using any sort of template system or when working with portlets within a portal. Will this be re-considered for a fix?

@smaier
Copy link

smaier commented Jul 24, 2013

thanks a lot!

@contrerasjf0
Copy link

Thaks a lot! this was help ful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests