Skip to main content

Dojo drop down date picker

6 replies [Last post]
sloanb
Offline
Joined: 2003-09-14

Has anybody else had issues with the dojo.dropdowndatepicker? When I'm using it on Mac Safari 3 and Firefox on the mac the date does not default to the current date. It defaults to 01/01/1970 in Safari in Firefox its NaN/NaN/NaN. Anybody else had this problem?

Regards

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
sloanb
Offline
Joined: 2003-09-14

After looking at the code the problem is the following code

if (typeof wargs.value != 'undefined' ) {
date = new Date(wargs.value);
} else {
date = new Date();
}

In my Case I haven't defined anything in the wargs.value however its being passed as undefined its value is "" so it is always attempting to create a Date object from the wargs.value which is going to be an invalid date. By adding the following code the problem was fixed:

if (typeof wargs.value != 'undefined' && wargs.value != "") {
date = new Date(wargs.value);
} else {
date = new Date();
}

Gregg/Carla am I misusing this widget and looking into something that isn't a problem? It does work if I pass a date as the value however I assumed that by not passing the date as a string it would create the current date time. Let me know.

Thanks

karthikbalait
Offline
Joined: 2007-12-05

hi sloanb,

is ur problem fixed?

if not i wnt to make sure if u r using the value attribute of dropdowndatepicker widget to get the date or to pass the date, if that is the case its wrong

u shud b using publish/subscribe mechanism to get the value, try to get the value in glue.js like this:

jmaki.subscribe("*onSelect", function(args) {
jmaki.log("glue.js : onSelect request from: " + args.id + " value=" + args.value);
var target = args.value;
});

karthikbalait

sloanb
Offline
Joined: 2003-09-14

The problem isn't getting the value from the widget itself. The problem is if I do not specify a value in the value arg my date that is listed by default is invalid without my code change. The problem is new Date() is never called because the prior condition is always returning true. I want to know if this is happening to others? Could somebody test this for me. Simple throw it on a page and view it and let me know if you get today's date or 1970.

thanks

carlavmott
Offline
Joined: 2005-02-10

Hi Sloan,

I'm able to create the widget correctly using the following:

defaults to todays date:

has the correct date:

I'm using JSP and PHP and both worked. Can you give more info? what version of jMaki? what platform.

Thanks,
Carla

azawawi
Offline
Joined: 2007-03-17

Hi Sloan,

Thanks for reporting this bug, I replicated your bug on windows (all browsers):
[code]

[/code]
This case can happen since we're not validating incoming date values and depending instead on date.parse behavior.

Windows:
Opera 9.24/ie7/firefox2/safari 3+, NaN/NaN/0NaN (Notice the zero)
Safari, 01/01/1970

if you try to alert(date) the value after new date(...), you'll get:
ie7/opera, "NaN"
safari 3+/firefox 2, "Invalid Date"

So the solution would be:
[code]
var date = new Date();
if(typeof wargs.value != 'undefined') {
if(wargs.value == /\d{2}\/\d{2}\/\d{4}/) {
date = new Date(value);
}
}
[/code]
I will commit the fix and it will be available soon in v1.0.3.

Best regards,
Ahmad

sloanb
Offline
Joined: 2003-09-14

You are very welcome. I appreciate the fix.