parmarmayur9090 / jquery-datepicker

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

Out-of-the-box function dpSetSelected produces an error in Firefox 3.6.12 #255

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
I am using inline configuration, after creating datepicker object I manually 
select the date, for example:
from_date = new Date("2010", "10", "24").toString();
$obj.dpSetSelected(from_date);

What is the expected output? What do you see instead?
I expect that there will be now javascript error. Indeed Opera, for example, 
reports nothing. However, using the Firebug in Firefox I see an error that 
comes from this line of code:
return _w.call(this, 'setSelected', Date.fromString(d), v, m, e);
line 389, file jquery.datePicker.js

Quick fix. 
Change the line to:
return _w.call(this, 'setSelected', new Date(d), v, m, e);

What version of the datepicker are you using? On what operating system? And 
Which Browser?
DatePicker.js.ID 102 2010-09-13 14:00:54Z

Please provide any additional information below.

Original issue reported on code.google.com by fra...@gmail.com on 26 Nov 2010 at 9:47

GoogleCodeExporter commented 8 years ago
Replace:

from_date = new Date("2010", "10", "24").toString();

With:

from_date = new Date("2010", "10", "24").asString();

The native toString() method on date objects returns a long string which is 
language and culture dependent. We provide as asString method which converts a 
Date object to a string based on your current Date.format.

Original comment by kelvin.l...@gmail.com on 26 Nov 2010 at 9:56

GoogleCodeExporter commented 8 years ago
Thanks! It works this way. 

I originally used asString() method, but created my from_date so

from_date = new Date("2010-10-24 00:00").asString();

Such code also generates an error in Firefox. Maybe this information will be 
useful for someone.

Original comment by fra...@gmail.com on 26 Nov 2010 at 10:02

GoogleCodeExporter commented 8 years ago
You could have done:

from_date = Date.fromString('2010-10-24').asString();

(assuming Date.format == 'yyyy-mm-dd')

If you are actually trying to set a specific date then there is no need to get 
a date object involved at all. You could just have done:

$obj.dpSetSelected('2010-10-24');

(again, assuming that Date.format is set to 'yyyy-mm-dd' - the thing to 
remember is that your string dates need to be in the same format as Date.format)

Original comment by kelvin.l...@gmail.com on 26 Nov 2010 at 10:06