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