Data binding 如何通过敲除数据绑定在dropdownlist中指定值

Data binding 如何通过敲除数据绑定在dropdownlist中指定值,data-binding,knockout.js,Data Binding,Knockout.js,我需要通过敲除数据绑定为DropDownlist指定一个值。 下面是ajax请求 $.ajax({ url: "getProducts.json", //GET method is used type: "post", //pass the data data: dat

我需要通过敲除数据绑定为DropDownlist指定一个值。 下面是ajax请求

$.ajax({
                       url: "getProducts.json",
                       //GET method is used
                       type: "post",
                       //pass the data
                       data: data,
                       dataType: 'json',
                       success : function(response) {
                           function inventoryProductRowsModel(inventoryProductRowsData, storeData) {
                            var self= this;
                            this.inventoryProductRowsData = inventoryProductRowsData;
                            this.storeData = storeData;
                           // var selectedStores = ko.observable();
                        }
                        var  inventoryProductRowsData = response.inventoryProductRows;
                        ko.applyBindings(inventoryProductRowsModel(inventoryProductRowsData,storeObject.storeRows), document.getElementById("inventoryProductId"));
                       }
});
下面是我处理下拉列表的方法

<select data-bind="options: storeData,optionsText: 'storeName',optionsValue: 'id'" id ="sellerStoreIdSizes" name="storeId" >

您需要创建viewmodel的实例,如下所示:

ko.applyBindings(new inventoryProductRowsModel(inventoryProductRowsData,storeObject.storeRows), document.getElementById("inventoryProductId"));