-
Notifications
You must be signed in to change notification settings - Fork 268
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
.fdatepicker('place') is not working #240
Comments
Was having the same problem that offset of the datepicker was wrong. When you open the reveal (modal), it puts a negative top value on the html tag. To make it work you could do something like this: $('#datePicker').fdatepicker({
// Datepicker options
}).on('show', function(){
var datePicker = $(this); // Datepicker input
if (datePicker.parents('.reveal').length > 0) { // if one of the parents has a reveal class where in a modal
setOffsetTopInReveal(datePicker); // recalc the top position
}
});
function setOffsetTopInReveal(datepicker) {
var offsetTop = datepicker.offset().top, // Offset from top of window
html = document.getElementsByTagName('html')[0], // get html tag
negativeOffset = Math.abs(parseInt(html.style.top)), // Get the negative offset and make it positive
newTop = offsetTop + negativeOffset + datepicker.outerHeight(); // Calculate new top ( offset top + negative offset (only positive) + outerHeight of input element )
// apply new top position
$('.datepicker').css({
top: newTop + 'px',
});
} |
I think I have a similar situation with foundation 6 reveal modals, where modals are using fixed positions (css: position: fixed). For fixed positioned html elements jquery calculates the offset relative to the screen top and not relative to the document top. As a consequence when you scroll down on the screen and open a modal dialog where you have a date picker, the small offset will result highly positioned datepicker widget. My workaround is something like this: I know it's very foundation specific, a nicer solution could be to search for parent elements that has fixed positions |
My datepicked is always taking the top value relative to the body tag. I have a long webpage and the input[type="text"] triggering the datepicker.
The form is inside a modal popup which again is triggered from the bottom of page.
I tried "$("#portalStartDate").fdatepicker('place');" but the datepicker is still taking top relative to the body tag. Adding a screengrab below to make question more clear. Please note when modal opens the body scrollbar is hidden.
The text was updated successfully, but these errors were encountered: