Convert Json parsed date to fit html5 input date

I am using Knockout to make a nice looking Gui like so


   viewModel = {
        lookupCollection: ko.observableArray()

    $(document).ready(function () {
            type: "GET",
            url:  "@Url.Action("GetView", "FakturaOmfangs", new {area = "" , id =})",
        }).done(function (data) {
            $(data).each(function (index, element) {
                var mappedItem =
                        FakturaId: ko.observable(element.FakturaId),
                        FakturaProdukterId: ko.observable(element.FakturaProdukterId),
                        Beskrivelse: ko.observable(element.Beskrivelse),
                        Periode: ko.observable(element.Periode),
                        EndDate: ko.observable(element.EndDate),
                        procent: ko.observable(element.procent),
                        Rabat: ko.observable(element.Rabat),
                        Pris: ko.observable(element.Pris),
                        Ialt: ko.observable(element.Ialt),
                        Value: ko.observable(element.Value),
                        Mode: ko.observable("display")

the EndDate is a Datetime? parsed from controller like this

  return Json(list, JsonRequestBehavior.AllowGet);

This is my input where i would like to put the Date into, so i can edit it.

<td><input class="form-control" type="date" data-bind="value: EndDate" /></td>

How do i format the date to the correct format? so that i can use it in input type=Date ?


Source: stackoverflow-javascript

Uncaught TypeError: Cannot read property ‘fromJSON’ of undefined

I am trying to display menu data after the ajax call returns from the following page:

    <link rel="stylesheet" type="text/css" href="">
    <!-- -->


    <h1>page loaded</h1>

</body> function OrderPageViewModel() { var self = this; // self.menu_loaded_success_callback = function(data) { // var retrieved_menu = data["menu"]; // = ko.observable(retrieved_menu); // console.log(retrieved_menu) // alert(data); // } // // self.get_data(menu_url).done(self.menu_loaded_success_callback); } var menu_url = "menu/get-menu"; get_menu_data = function(url_ending){ console.log("running get_data"); var URL = "/api/&/".replace("&", url_ending); console.log("URL: ", URL); return $.ajax({ dataType: "json", url: URL, // type: "GET", }); } get_menu_data(menu_url).done(function(data){ var vm = new OrderPageViewModel(); console.log(data); vm = ko.mapping.fromJSON(data); ko.applyBindings(vm); }).fail(function(){ alert("failed"); }); // ko.applyBindings(new OrderPageViewModel());

enter image description here

I followed the example at wait for ajax result to bind knockout model and it is saying Uncaught TypeError: Cannot read property 'fromJSON' of undefined

Any help appreciated

Source: stackoverflow-javascript