Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting jQuery UI's datepicker to always open in a certain direction?

I'm using jQuery UI's datepicker control in a position: fixed toolbar at the bottom of my page. Occasionally, on random computers, the datepicker appears below the toolbar, which means it's off the page and impossible to view or interact with.

Is there a way to force the positioning of the datepicker control to always be above and to the right of its <input>?

like image 256
ceejayoz Avatar asked Oct 06 '09 15:10

ceejayoz


People also ask

How do I fix my datepicker position?

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.

How do I set a datepicker range?

To set date range of one month from current date, we will use 'M' option to "+1" for maxDate and for minDate "0" So the current date becomes the value of minDate. See below jQuery code. $(document). ready(function(){ $("#txtDate").

How do I maxDate datepicker?

Try this: $("#datepicker"). datepicker({ minDate: -0, maxDate: new Date(2013, 1, 18) }); If you want use hard coded date, use the new Date(2013, 1, 18) pattern.

What is minDate and maxDate in jQuery datepicker?

If you like to restrict access of users to select a date within a range then there is minDate and maxDate options are available in jQuery UI. Using this you can set the date range of the Datepicker. After defining these options the other days will be disabled which are not in a defined range.


1 Answers

The only way to be certain (for the jQueryUI version of datepicker) is to disable the functionality of the datepicker that tries to render inside the viewport. Here's a way to do it without modifying the source code files:

$.extend(window.DP_jQuery.datepicker,{_checkOffset:function(inst,offset,isFixed){return offset}});

on later versions of JQuery UI try:

$.extend($.datepicker,{_checkOffset:function(inst,offset,isFixed){return offset}});

That just nukes the _checkOffset function inside datepicker that makes it squirrelly. Then you can use the .ui-datepicker css to make sure it stays fixed if that's what you're after. More info at how-to-control-positioning-of-jqueryui-datepicker.

like image 117
Purrell Avatar answered Sep 22 '22 02:09

Purrell