Convert Json parsed date to fit html5 input date

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

Javascript:

   viewModel = {
        lookupCollection: ko.observableArray()
    };

    $(document).ready(function () {
        $.ajax({
            type: "GET",
            url:  "@Url.Action("GetView", "FakturaOmfangs", new {area = "" , id = ViewBag.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")
                    };
                console.log(mappedItem);
                viewModel.lookupCollection.push(mappedItem);
            });
            ko.applyBindings(viewModel);
        });
    });

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 ?

Thanks.
Benny.


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:

<head>
    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css">

    https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.1/knockout-min.js
    https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js
    <!-- https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/js/bootstrap.min.js
    https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.js -->
</head>


<body>

    <h1>page loaded</h1>

    
</body> function OrderPageViewModel() { var self = this; // self.menu_loaded_success_callback = function(data) { // var retrieved_menu = data["menu"]; // self.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