views:

6184

answers:

4

Any idea how to get the DatePicker to appear at the end of the associated text box instead of directly below it? What tends to happen is that the text box is towards the bottom of the page and the DatePicker shifts up to account for it and totally covers the text box. If the user wants to type the date instead of pick it, they can't. I'd rather have it appear just after the text box so it doesn't matter how it adjusts vertically.

Any idea how to control the positioning? I didn't see any settings for the widget, and I haven't had any luck tweaking the CSS settings, but I could easily be missing something.

A: 

This link might help you out:

jquery.datePicker example: datePicker with different positioning

Kev

Kev
-1: This actually refers to a different datepicker plugin
Adrian Grigore
@adrian - maybe so, but OP seemed happy enough with the answer.
Kev
I understand, but it's quite confusing for others stumbling across this post after researching the same problem. SO ranks quite high in lots of development-related search queries on google. It's not uncommon for me to find solutions to my dev-related problems this way. I stumbled across this thread the same way and your post only confused me.
Adrian Grigore
+8  A: 

The accepted answer for this question is actually not for the jQuery UI Datepicker. To change the position of the jQuery UI Datepicker just modify .ui-datepicker in the css file. The size of the Datepicker can also be changed in this way, just adjust the font size.

+14  A: 

Here's what I'm using:

$('input.date').datepicker({
    beforeShow: function(input, inst)
    {
        inst.dpDiv.css({marginTop: -input.offsetHeight + 'px', marginLeft: input.offsetWidth + 'px'});
    }
});

You may also want to add a bit more to the left margin so it's not right up against the input field.

+5  A: 

I do it directly in the CSS:

.ui-datepicker { 
  margin-left: 100px;
  z-index: 1000;
}

My date input fields are all 100px wide. I also added the z-index so the calendar also appears above AJAX popups.

I don't modify the jquery-ui CSS file; I overload the class in my main CSS file, so I can change the theme or update the widget without having to re-enter my specific mods.

Christian Lescuyer