Login Register

timetextbox and datetextbox prefill data not available in ISO format

I'm trying to get the timetextbox and datetextbox up and running on an existing platform, and I'm stuck. My system already accepts mm-dd-yyyy formating (and I worked that out with serialize:) but it also pre-fills with the same format. The problem is dojo will only accept yyyy-mm-dd as a valid format:

However, you must provide numbers and dates from the server in JavaScript format. This goes for the value property and the min and max constraint values. You may do the conversion at the server or through the dojo.getXhr callback.

(see the manual at http://dojotoolkit.org/book/dojo-book-0-9/part-2-dijit/form-validation-specialized-input/textbox-validating-currency-number)
Can one use the dojo.getXhr callback on a form that is NOT going over an ajax request, and if so, how?

It strikes me as odd, that there is a provision for formating data in a server friendly format but not being able to receive it in a server friendly format. It makes it hard for me to write code that will still work in the event of dojo failing, without having the user edit data on each round trip to the server

Ugly but working fix

Well it isnt pretty but it works...

function sni(){
        n = dojo.query(".DojoDate");

        for(i=0;i<n.length;i++) {
               
                        sv = n[i].defaultValue.split("-");
// dojo looks at default value in FF and safari
                        n[i].defaultValue = sv[2]+"-"+sv[0]+"-"+sv[1];
// and in IE (ack) we look at value
                        n[i].value = n[i].defaultValue;
        }

        dojo.declare("HumanDateTextBox",[dijit.form.DateTextBox], {
                        serialize: function(d, options) {
                        return dojo.date.locale.format(d, {selector:"date", datePattern:"MM-dd-yyyy", locale:"en"}).toLowerCase();
                }
        });
// parse by hand after date is fixed
        dojo.parser.parse();

}

dojo.addOnLoad( sni );

Hopefully this helps someone out... but we still need an unserialize function

Ugly but working fix

Well it isnt pretty but it works...

function sni(){
        n = dojo.query(".DojoDate");

        for(i=0;i<n.length;i++) {
               
                        sv = n[i].defaultValue.split("-");
// dojo looks at default value in FF and safari
                        n[i].defaultValue = sv[2]+"-"+sv[0]+"-"+sv[1];
// and in IE (ack) we look at value
                        n[i].value = n[i].defaultValue;
        }

        dojo.declare("HumanDateTextBox",[dijit.form.DateTextBox], {
                        serialize: function(d, options) {
                        return dojo.date.locale.format(d, {selector:"date", datePattern:"MM-dd-yyyy", locale:"en"}).toLowerCase();
                }
        });
// parse by hand after date is fixed
        dojo.parser.parse();

}

dojo.addOnLoad( sni );

Hopefully this helps someone out... but we still need an unserialize function