Changes between Initial Version and Version 1 of Ticket #8050


Ignore:
Timestamp:
Nov 10, 2008, 9:28:32 AM (11 years ago)
Author:
bill
Comment:

Hi Spidey,

inline DateTextBox.value = "2008-11-09" programmatic code DateTextBox.value = new Date ("2008-11-09")

This issue has caused confusion before but it's by design. In markup all parameters are specified as strings and the parser does type conversion. However, when creating widgets programatically the user must pass in the right types for parameters. The value parameter is a Date object, as listed in http://api.dojotoolkit.org/jsdoc/dijit/1.2/dijit.form.DateTextBox.

As for the Date.prototype.json thing, that's really an issue with dojo.toJson(), not with the widget. Note that attr('value') for DateTextBox returns a Date object and works correctly w/out the Date.prototype.json hack.

However - shouldn't this function be part of the Date object?

By policy dojo doesn't modify native javascript "classes" like Array or Date, because we don't want to do something that interferes w/other toolkits / affects code outside of dojo. Perhaps dojo.toJson() should be enhanced to have a registry of types and serializers for them. Of course, that won't solve problems with dojo.fromJson(), which doesn't know which fields are supposed to be dates.

Anyway, the idea of a registry is covered in other ticket(s).

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #8050

    • Property Status changed from new to closed
    • Property Resolution changed from to wontfix
  • Ticket #8050 – Description

    initial v1  
    1 Context: added a DateTimeBox to a Form programmatically. The first issue was the the date value was not showing up. Luckily the test indicated this methodology which varies from the inline code. (inline DateTextBox.value = "2008-11-09" programmatic code DateTextBox.value = new Date ("2008-11-09").
     1Context: added a !DateTimeBox to a Form programmatically. The first issue was the the date value was not showing up. Luckily the test indicated this methodology which varies from the inline code. (inline {{{DateTextBox.value = "2008-11-09"}}} programmatic code {{{DateTextBox.value = new Date ("2008-11-09")}}}.
    22
    33The second issue is that when the values were extracted from the form, the date's value was empty. This is what had to be done to view the date's value.
    4        
     4{{{
    55  function getValues (arguments) {
    66      Date.prototype.json = function(){
     
    1111       alert("Object is: " + dojo.toJson(obj, true));
    1212   }
    13 
     13}}}
    1414Thankfully the Date.prototype.json code snippet was in the tests as well. However -  shouldn't this function be part of the Date object? Users shouldn't have to read the tests to determine how a Date function should be extended in order to find the value of a date.
    1515