Anita44 / jquery-datepicker

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

Unable to unset dates #174

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I set 2 datepickers inside a jquery-ui dialog. (One to choose a start date
and the other to choose the end date)
When I choose the 2 dates it's ok.

I close the form and open it again and the two datepicker are set with the
values I choosed before.
I try the dpSetSelected method on the dialog close event to unset the date
after the form validation but it doesn't work.
When the close function of the form is triggered, the datepicker is already
closed, is that the reason why I can't unset dates?

You can find my tests on :
http://aurelien.kochalski.free.fr/Projets/Test_DatePicker_Unset/

I used this version : 84 2009-08-05 17:54:35Z
On Windows XP Pro SP2
With Firefox

Original issue reported on code.google.com by Aurelien...@gmail.com on 10 Mar 2010 at 3:58

GoogleCodeExporter commented 9 years ago
I'm having a similar problem. I have a DatePicker with single selection and I 
need to programatically unset the selected date when some button is clicked, 
and it does not work.
I tried $('#datepicker').dpSetSelected(dpGetSelected()[0].toString()) and also 
setting manually the date with no results.

Cheers!

Original comment by brafa...@gmail.com on 15 Nov 2010 at 3:00

GoogleCodeExporter commented 9 years ago
Hi,

Did you ever figure your problem out Aurelien? I must have missed this message 
when it was posted...

@brafales - Try something more like

$('#datepicker').dpSetSelected($('#datepicker').dpGetSelected()[0], false);

(you need to pass in false to unselect the date and you need to call 
dpGetSelected on a reference to the date picker....)

Original comment by kelvin.l...@gmail.com on 15 Nov 2010 at 3:17

GoogleCodeExporter commented 9 years ago
No, finally I never find a solution for that, sorry!

Original comment by Aurelien...@gmail.com on 15 Nov 2010 at 3:31

GoogleCodeExporter commented 9 years ago
Thanks Kevin, that worked, however, when I deselect a date, the event 
dpSelectedDate is fired and this breaks some things for me. Is there any way to 
know if the selection event was from a selection or from an unselection? Maybe 
checking some parameter from the e or $td elements?

Original comment by brafa...@gmail.com on 16 Nov 2010 at 8:20

GoogleCodeExporter commented 9 years ago
@Aurelien:
It looks like it your code you are selecting one and deselecting the other date:

$('.date-picker').dpSetSelected(js_datedebut.asString(), true); // On 
désélectionne la date dans le picker
$('.date-picker').dpSetSelected(js_datefin.asString(), false); // On 
désélectionne la date dans le picker

Try passing false both times...

@brafales:

As described in the documentation, the dateSelected event has a status argument 
passed to it:

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

"dateSelected(event, date, $td, status) Triggered when a date is selected. 
event is a reference to the event, date is the Date selected, $td is a jquery 
object wrapped around the TD that was clicked on and status is whether the date 
was selected (true) or deselected (false)"

Hope it helps,

Kelvin (not Kevin!)

Original comment by kelvin.l...@gmail.com on 16 Nov 2010 at 9:57

GoogleCodeExporter commented 9 years ago
p.s. I like you skin and implementation of the date picker Aurelien

Original comment by kelvin.l...@gmail.com on 16 Nov 2010 at 9:58