Opened 5 years ago

Closed 3 years ago

#17565 closed defect (patchwelcome)

dojox/mobile/DatePicker does not send user’s input back to the value attribute

Reported by: Akira Sudoh Owned by: Patrick Ruzand
Priority: undecided Milestone: 1.13
Component: DojoX Mobile Version: 1.9.1
Keywords: Cc:
Blocked By: Blocking:

Description

dojox/mobile/DatePicker does not send user’s input back to the value attribute. It’s not fortunate for applications integrating dojox/mobile/DatePicker and dojox/mvc, given such application wants to bind the value attribute a property in data model.

Currently application needs something like the aspect.after() portion in below example to work around that:

<!DOCTYPE html>
<html>
    <head>
        <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/dojo/1.9.1/dojox/mobile/deviceTheme.js" data-dojo-config="mblThemeFiles: ['base', 'DatePicker']"></script>
        <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/dojo/1.9.1/dojo/dojo.js" data-dojo-config="async: 1, parseOnLoad: 0"></script>
        <script type="text/javascript">
            require([
                "dojo/_base/array",
                "dojo/aspect",
                "dojo/date/locale",
                "dojo/date/stamp",
                "dojo/Stateful",
                "dojox/mvc/at",
                "dojox/mobile/parser",
                "dojox/mobile/DatePicker",
                "dojox/mvc/Output"
            ], function(array, aspect, locale, stamp, Stateful, at, parser, DatePicker){
                window.at = at;
                window.model = new Stateful({
                    date: stamp.toISOString(new Date())
                });
                aspect.after(DatePicker.prototype, "startup", function(){
                    var self = this,
                        slots = this.slots;
                    array.forEach(slots, function(slot){
                        self.own(slot.watch("value", function(){
                            var pattern = slots[0].pattern + "/" + slots[1].pattern + "/" + slots[2].pattern;
                            self._set("value", stamp.toISOString(locale.parse(slots[0].get("value") + "/" + slots[1].get("value") + "/" + slots[2].get("value"), {datePattern: pattern, selector: "date"})));
                        }));
                    });
                });
                parser.parse();
            });
        </script>
    </head>
    <body>
        <div data-dojo-type="dojox/mobile/DatePicker" data-dojo-props="value: at(model, 'date')"></div>
        <div>Date picker value: <span data-dojo-type="dojox/mvc/Output" data-dojo-props="value: at(model, 'date')"></span></div>
    </body>
</html>

Change History (3)

comment:1 Changed 5 years ago by Patrick Ruzand

Milestone: tbd1.10
Owner: set to Patrick Ruzand
Status: newassigned

comment:2 Changed 5 years ago by Patrick Ruzand

Milestone: 1.10tbd

comment:3 Changed 3 years ago by dylan

Milestone: tbd1.12
Resolution: patchwelcome
Status: assignedclosed

Given that no one has shown interest in creating a patch in the past 2+ years, I'm closing this as patchwelcome. Please let us know if you would like to get involved in helping make this change to Dojo!

Note: See TracTickets for help on using tickets.