locked
How to bind a new list of values to UL when Onchange event of Select option is fired using knockout.js? RRS feed

  • Question

  • User1657665600 posted
    <p><span>I'm struggling with Knockout JS. In my spa, after page loaded event ul showing some list of values from database successfully. Below is the code</span></p>
    Tuesday, August 13, 2013 3:51 AM

Answers

  • User1657665600 posted

    For this scenario, made Jquery Ajax call , then only it will retrieve data are bind to UL.

    function StrikeAppViewModel() {
    var self = this;
    self.Contacts = ko.observable($.parseJSON(localStorage["ContactsTable"]));
    
    self.SearchContacts = function () {
    
        $.ajax({
            url: 'http://localhost:12345/api/Contact',
            type: 'GET',
            dataType: 'jsonp',
            data: { ID: id },
            context: this,
            success: function (result) {
                debugger;
                self.Contacts(result);
    
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
    
                alert(errorThrown);
            }
        });
    
    }   };



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 13, 2013 6:54 AM