chandrajavin / jquery-datepicker

Automatically exported from code.google.com/p/jquery-datepicker
0 stars 0 forks source link

Interactive selectedDates Data array from PHP #281

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi Kelvin,

In order to edit / update presence day of a worker, i need those dates which 
are retrieved from MySQL to be displayed in this widget when i trigger dpClosed.

For example : 

$(function()
{
    $('#text1')
        .datePicker(
        {
            displayClose:true,
            closeOnSelect:false,
            selectMultiple:true,
            selectedDates: ['2011/05/09','2011/05/10'], //dates from DB
            numSelectable:3,
            renderCallback:function($td, thisDate, month, year)
            {
                if (thisDate.isWeekend()) {
                    $td.addClass('weekend');
                    $td.addClass('disabled');
                }
                if (thisDate.asString() == '2011/05/09') {
                    $td.addClass('selected');
                }
                if (thisDate.asString() == '2011/05/10') {
                    $td.addClass('selected');
                }
            }
        })
        .bind(
            'dpClosed',
            function(e, selectedDates)
            {
                var date1 = [];
                for (var i=0;i<selectedDates.length;i++) {
                    var tgl = selectedDates[i].getDate().toString();
                    if (tgl.length == 1) tgl = "0" + tgl;
                    var bln = (selectedDates[i].getMonth()+1).toString();
                    if (bln.length == 1) bln = "0" + bln;
                    var thn = selectedDates[i].getFullYear().toString();
                    date1[i] = thn + "/" + bln + "/" + tgl;
                }
                date1.sort();
                $('#text1').val(date1.join(" "));
            }
        );
});

#text1 is preloaded with dates : 2011/05/09 and 2011/05/10 (from MySQL)

When i click on #text1, the calender displays 2 selected dates but when i close 
the datepicker (dpClosed), #text1 is now clear whereas it should contain 
2011/05/09 and 2011/05/10

How can i resolve this ?

Original issue reported on code.google.com by Siwan1...@gmail.com on 13 May 2011 at 4:14