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

Datepicker in bootstrap-modal #325

Closed
piwo1984 opened this issue Jan 17, 2013 · 15 comments
Closed

Datepicker in bootstrap-modal #325

piwo1984 opened this issue Jan 17, 2013 · 15 comments

Comments

@piwo1984
Copy link

Hi,

I'm using the bootstrap-modal extension from here https://github.com/jschr/bootstrap-modal/
When I attach a datepicker to an input within a modal the picker is positioned far away under the input. I've extended your 'place'-method. Maybe you need it:

place : function() {
            if (this.isInline)
                return;
            var zIndex = parseInt(this.element.parents().filter(function() {
                return $(this).css('z-index') != 'auto';
            }).first().css('z-index')) + 10;
            var offset = this.component ? this.component.offset() : this.element.offset();
            var height = this.component ? this.component.outerHeight(true) : this.element.outerHeight(true);
            var isInModal = this.element.parents('.modal').length;
            var top = offset.top + height;
            if(isInModal) {
                top = top - 40;
            }
            this.picker.css({
                top : top,
                left : offset.left,
                zIndex : zIndex
            });
        },
@KOTRET
Copy link

KOTRET commented Jan 17, 2013

it would help to add some markdown to this post as its not readable...
to wrap the code:

[your stuff here]

@tiagobnobrega
Copy link

I just couldn't understand the modal part. Let me see if got it right.

place : function() {
            if (this.isInline) return;
             //get the first parent z-index, then add 10...
            var zIndex = parseInt(this.element.parents().filter(function() {
                return $(this).css('z-index') != 'auto';
            }).first().css('z-index')) + 10;
            //calc offset and height for element/component...
            var offset = this.component ? this.component.offset() : this.element.offset();
            var height = this.component ? this.component.outerHeight(true) : this.element.outerHeight(true);
            var isInModal = this.element.parents('.modal').length;
            var top = offset.top + height;

            //if the element is in a modal subtract 40 from position. why this?
            //with this part the calendar showed covering part of the element.
           // I'm guessing is because your calendar is positioned above the element,
           // In my case its' positioned below the element. So I removed it and worked like charm!
           // Maybe some check is needed here.
            if(isInModal) {
                top = top - 40;
            }
            this.picker.css({
                top : top,
                left : offset.left,
                zIndex : zIndex
            });
        }

@piwo1984
Copy link
Author

Hi titbarros,

this is strange. I've attached two images to show you what I mean.
This image shows the "default-view"
datepicker_without_modifications pdf

With my modifications I get the following result
datepicker_with_modifications pdf

I've tested it with several browsers like ie, firefox, chrome and safari.

@Yohn
Copy link

Yohn commented Jan 24, 2013

maybe its your version of the datepicker? I'm using the newest version in jschr's modal plugin and I'm not experiencing this problem either..

@piwo1984
Copy link
Author

I've just updated both, the datepicker and the modal........still the same

@ghost
Copy link

ghost commented Jan 29, 2013

I had the same issue. My problem was in my personal css, I put a margin-top for section tags. Hope that will help you.

@timraymond
Copy link

I've just replicated this with the latest version of this plugin.

timraymond added a commit to timraymond/bootstrap-datepicker that referenced this issue Apr 11, 2013
Placing a datepicker as a component in a bootstrap modal would bind to
the body rather than the element of the modal. This would cause the
datepicker to scroll with the body while the modal remained in place.
This patch binds the datepicker dropdown to the element where it was
invoked and changes the computation of the offset to use position(),
since offset() was relative to the window. Fixes uxsolutions#325.
@lpaul7
Copy link

lpaul7 commented Sep 11, 2013

Same issue with bs 3. Fixed by setting z-index to 1050.

@MaxxSoftware
Copy link

Have the same issue. And @timraymond fix doesn't help

@jschmiede
Copy link

The easiest way to hack this issue, is to set the z-index to 1050+ on the .modal-dialog div, so the place function sets the picker.css.z-index to 1060+, as shown L550
note: the .modal-backdrop div z-index is set to 1040 by default
here a sample

@acrobat
Copy link
Member

acrobat commented Dec 26, 2014

Can you guys confirm this is still an issue with the current master (should be fixed in 1.3.1), as #710 fixes issues with z-index

@giaule56
Copy link

giaule56 commented Jan 2, 2015

I have the same problem when scrolling on popup like this
errordatepicker

I cannot find the solution

@hebbet
Copy link
Contributor

hebbet commented Jan 2, 2015

@giaule56 did you upgrade to 1.3.1?

@acrobat
Copy link
Member

acrobat commented Jan 10, 2015

I think the issue @giaule56 will be fixed in 1.4.0 with the new container option #918 and the placement fixes from #1227

@acrobat
Copy link
Member

acrobat commented Jan 11, 2015

Fixed in #1227

@acrobat acrobat closed this as completed Jan 11, 2015
@acrobat acrobat mentioned this issue Jan 11, 2015
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.