1

我需要通过敲除数据绑定为 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" >
4

1 回答 1

0

您需要像这样创建视图模型的实例:

ko.applyBindings(new inventoryProductRowsModel(inventoryProductRowsData,storeObject.storeRows), document.getElementById("inventoryProductId"));
于 2013-05-30T05:52:59.367 回答