$date1 = $('<div />')

http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerMultiMonth.html

$date1 = $('<div />')
                .datePicker({inline:true})
                .bind(
                        'dpMonthChanged',
                        function(event, displayedMonth, displayedYear)
                        {
                                $date2.dpSetDisplayedMonth(displayedMonth+1, 
displayedYear);
                        }
                )
                .bind(
                        'dateSelected',
                        function(event, date, $td, status)
                        {
                                $date2.dpSetSelected(date.asString(), status, 
false);
                        }
                );
        // remove the "forward" navigation from the first date picker
        $('.dp-nav-next', $date1).html('');
        // create the right hand datePicker and add the relevant event
listeners to sync it to the left hand one...
        $date2 = $('<div />')
                .datePicker({inline:true})
                .bind(
                        'dpMonthChanged',
                        function(event, displayedMonth, displayedYear)
                        {
                                $date1.dpSetDisplayedMonth(displayedMonth-1, 
displayedYear);
                        }
                )
                .bind(
                        'dateSelected',
                        function(event, date, $td, status)
                        {
                                $date1.dpSetSelected(date.asString(), status, 
false);
                        }
                );
        // remove the "backward" navigation from the first date picker
        $('.dp-nav-prev', $date2).html('');
        // initialise the date pickers to consecutive months ($date1 defaults
to this month so set $date2 to next month)
        var now = new Date();
        $date2.dpSetDisplayedMonth(now.getMonth()+1, now.getFullYear());
        // add the generated combined plugin to the document
        $('#multimonth').html('').append($date1, $date2);

Reply via email to