Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change jQuery UI Datepicker Z-Index value?

I am forced to use an older version of jquery ui which is 1.8.10. The datepicker in this version had a bug inside of the z-index setting which at times made it appear under other controls. I am simply wanting to adjust the z-index of the dp so that it appears on top of the other controls. I attempted to change the z-index into the .js file but that failed. I'v read you have to set this value on the aftershow event because the value will get overwritten if its earlier(not sure if this is true). Here is an example of how im creating an instance of the dp...i also attached a timepicker to the datepicker.

        $(function () {
        $("input[id$='txtPreviousCutOff']").datetimepicker({
            timeFormat: "hh:mm tt",
            stepMinute: 5
        });
        $("#dpimage6").click(function () {
            $("input[id$='txtPreviousCutOff']").datepicker("show")
        });
    });
like image 834
user1732364 Avatar asked Dec 11 '12 16:12

user1732364


People also ask

How can change date format in jQuery ui DatePicker?

inside the jQuery script code just paste the code. $( ". selector" ). datepicker({ dateFormat: 'yy-mm-dd' });

How do I set a DatePicker range?

Steps to add Datepicker – $(document). ready(function(){ $("#setMin,#setMax"). datepicker({ dateFormat: "yy-mm-dd" }); $('#datepicker'). datepicker({ dateFormat: "yy-mm-dd", maxDate:'+1m +10d', minDate: -10 }); });

How do I change 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 change my DatePicker size?

By default DatePicker has standard height and width (height: '30px' and width: '143px'). You can change this height and width by using height and width property respectively.


2 Answers

.ui-datepicker-div { z-index: 999999; }

or with js:

$(function () {
    $("input[id$='txtPreviousCutOff']").datetimepicker({
        timeFormat: "hh:mm tt",
        stepMinute: 5
     });
     $("#dpimage6").click(function () {
        $("input[id$='txtPreviousCutOff']").datepicker("show")
    });
    $('.ui-datepicker-div').css('zIndex', 999999);
});
like image 85
Magicmarkker Avatar answered Sep 21 '22 14:09

Magicmarkker


You would need to apply styles to the ui-widget-content class

.ui-widget-content
{
    z-index: 100; 
}

Make sure to have the class added with better specificity so that it overrides the UI styles

#datepicker.ui-widget-content {}
like image 44
Sushanth -- Avatar answered Sep 18 '22 14:09

Sushanth --