0

I cant find any decent examples of implementing the WinJS.UI.DatePicker control. Specifically I am not able to retrieve the "current" attribute from the "change" event. In my example below "eventInfo.current" is undefined?

    <h2>Date Picker Control</h2>
        <label for="datePickerDiv">
            Enter A Date:
        </label>
        <div id="date" data-win-control="WinJS.UI.DatePicker"></div>
        <div id="datePickerOutput"></div>

    //datePicker Control
    var date = document.getElementById("date");
    var datePicker = date.winControl;
    datePicker.addEventListener("change", dateChanged, false);

    function dateChanged(eventInfo) {
        var datePickerOutput = document.getElementById("datePickerOutput");
        datePickerOutput.innerText = "Selected Date: " + eventInfo.current + '.';
    }

Edited by dawbin

2
Contributors
2
Replies
5
Views
2 Years
Discussion Span
Last Post by dawbin
0

Is current undefined or is eventInfo?
Where are you creating the datepicker object? E.g. where is this line:
var datePicker = new WinJS.UI.DatePicker(element, options);
I only looked into this briefly just now so what I'm asking is, is line 8 and 9 in your code the same as the object instantiation above?

0

I figured it out, was working from a bad sample code...

    function birthChanged(eventInfo) {

        //save roaming data
        var birth = document.getElementById("birth");
        var datePicker = birth.winControl;
        var appData = Windows.Storage.ApplicationData.current
        var roamingSettings = appData.roamingSettings;
        roamingSettings.values["birth"] = datePicker.current;

    }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.