Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery DatePicker how to disable auto day selection while browsing calendar?

In jQuery DatePicker there is one annoying thing, if you using it as a calendar and depend on selected date. While navigating from month to month it keep selected day activated for all months. I know that this issue exist for more than 6 months and I have reported it to jQuery Team.However I would like to know is there any workarounds or how to disable this behaviour?

Calendar example can be found here

like image 494
Nazariy Avatar asked Oct 01 '10 14:10

Nazariy


1 Answers

here's a workaround I figured out.

$(function() {

    $("#datepicker").datepicker({
        onChangeMonthYear: function(year, month, inst) {
            var bMonth = (new Date(this.value)).getMonth() != month - 1;
            var bYear = (new Date(this.value)).getFullYear() != year;
            if (bMonth || bYear) {
            setTimeout(function() {
                $('.ui-state-active').removeClass('ui-state-active');
            }, 5);
            }
        }
    });
});​

crazy demo

like image 176
Reigel Avatar answered Oct 13 '22 07:10

Reigel