Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change option dynamically in JQuery UI DatePicker fails

I want to make date range selection using jquery-ui datepicker. First change at #dteStart succeed to set minDate at #dteEnd. But #dteEnd failed to refresh its options on next change, if i alert DateOptions.minDate its value changed according to dateMin.

Maybe i miss something here...

$(document).ready(function () 
{
    $("#dteStart").datepicker()
    .change(function () 
    {
        dateStart = $(this).datepicker('getDate');
        dateMin = new Date(dateStart.getTime());
        dateMin.setDate(dateMin.getDate() + 1);

        var DateOptions = {
            dateformat: "mm/dd/yyyy",
            minDate: dateMin
        }
        $("#dteEnd").datepicker(DateOptions);
    });
});

TIA,

REV

like image 759
v14nt0 Avatar asked Dec 07 '10 03:12

v14nt0


1 Answers

put $("#dteEnd").datepicker("destroy"); before $("#dteEnd").datepicker(DateOptions); and it will work fine.

like image 120
TheVillageIdiot Avatar answered Oct 14 '22 03:10

TheVillageIdiot