Adil Malik
Adil Malik

Reputation: 6357

datepicker jump to a date

I want datepicker to jump to a date but I don't want to select that date. I saw a method setDate in the documentation. I want exactly what it does but it should not select the date.

e.g.

Upvotes: 2

Views: 2449

Answers (2)

Guillaume Poussel
Guillaume Poussel

Reputation: 9822

Based on jQuery UI source code and my previous tries on a similar topic, I wrote this function:

function gotoDate($j, month, year) {
    $j.each(function (i, el) {
        var inst = $.datepicker._getInst(el);
        inst.drawMonth = inst.selectedMonth = month;
        inst.drawYear = inst.selectedYear = year;
        $.datepicker._notifyChange(inst);
        $.datepicker._adjustDate(el);
    });
}

This is based on undocumented method calls and could change in a future version of jQuery UI.

See a live fiddle here

Upvotes: 4

ggzone
ggzone

Reputation: 3711

you can use setDate but remove the value after that so the input field with the date is empty after that "jump"

Upvotes: 0

Related Questions