madalinignisca / jquery-datepicker

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

Select/Deselect week with datePickerMultiMonth inline mode #96

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hello,
I'd like to deselect a selected week with datePickerMultiMonth inline mode,
like selectMultiple mode with single day selection.
I read this issue
http://code.google.com/p/jquery-datepicker/issues/detail?id=13&can=1, but
if I click on a previous selected week I don't have dateSelected event fired.
This is what I have:
$(function()
            {
        $('#multimonth').datePickerMultiMonth({
            numMonths: 4,
            inline: true,
            selectMultiple:true,
            selectWeek:true

        }).bind(
            'click',
            function()
            {
                                //....
                return false;
            }
        ).bind(
            'dateSelected',
            function(e, selectedDate, $td)
            {
                alert('You selected ' + selectedDate);
            }
        );
        });

I'm using version linked in your demo at
http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerSelectWeek.
html
on Gnu/Linux with Firefox 3.0.11.
Thanks in advance.

Original issue reported on code.google.com by manliomo...@gmail.com on 18 Jul 2009 at 3:47

GoogleCodeExporter commented 8 years ago
Hi,

It sounds like you may be running into some problems related to the fact that
datePickerMultiMonth actually wraps individual date pickers without exposing 
all of
their methods or events (see also issue 79). I will look into this problem as 
soon as
I have some spare time (but I'm afraid I can't guarantee that that will be soon 
:( ),

Cheers,

Kelvin :)

Original comment by kelvin.l...@gmail.com on 19 Jul 2009 at 12:45

GoogleCodeExporter commented 8 years ago
Hi,
thank you for your reply.
I've found a little (probably dirty) workaround to achieve my purpose.
In jquery.datePicker.js at line 674
I changed from 
$td[v ? 'addClass' : 'removeClass']('selected');
to
$td.parent().children()[v ? 'addClass' : 'removeClass']('selected');

and to get monday of the selected week I made this:

 $(function() {
                $('#multimonth').datePickerMultiMonth({
                    numMonths: 4,
                    inline: true,
                    selectMultiple: true,
                    //selectWeek:true,
                    startDate: startDateValidity,
                    endDate: endDateValidity
                }).bind(
            'dateSelected',
            function(e, selectedDate, $td) {
               var monday;
               if(selectedDate.getDay() != 1)
               {
                   if(selectedDate.getDay() == 0){
                      monday = new
Date(selectedDate.getFullYear(),selectedDate.getMonth(),selectedDate.getDate()-6
);
                   }
                   else{
                     monday = new
Date(selectedDate.getFullYear(),selectedDate.getMonth(),selectedDate.getDate()-(
selectedDate.getDay()-1));
                   }
                }
                else
                    monday=selectedDate;

                    //....etc.
             });
              });

As you can see I don't use anymore selectWeek:true.
I repeat probably is a bad workaround, but should work. Thank you for your time 
and
hope this can be useful for someone.
Bye.

Original comment by manliomo...@gmail.com on 24 Jul 2009 at 4:19

GoogleCodeExporter commented 8 years ago
Hello,
I'd like to deselect a selected week with datePickerWeek inline mode,
like selectMultiple mode with single day selection.

Original comment by bharat.m...@gmail.com on 27 Dec 2014 at 1:02