Tag: ko.observablearray

将值推入嵌套的ko.observableArray

我希望将供应商列表嵌入到我从服务器获得的现有JSON Payload中,具体取决于JSON Payload中的项是否需要供应商。 我最终想要的是这样的事情: { “ProductName”: “Product123”, “RequiredComponents”: “CAP 10% H/Vol”, “StockCode”: “142111411”, “RequiredQtyByBom”: 4, “QtyUnassignedInWarehouse”: 0, “QtyAllocatedInWarehouse”: 40, “PCBReference”: “442C”, “QtyOnOrder”: 26, “Vendors”: [], “RequireVendor”: false }, { “ProductName”: “Product123”, “RequiredComponents”: “Screws”, “StockCode”: “Screws”, “RequiredQtyByBom”: 1, “QtyUnassignedInWarehouse”: 0, “QtyAllocatedInWarehouse”: 14, “PCBReference”: “Screws”, “QtyOnOrder”: 26, “Vendors”: [ {“VendorID”: “3”, “VendorName”: “ABC Supplier”, “VendorMOQ”: 50000, “VendorItemPrice”: […]

Knockout JS中的相关可观察数组

我已经开始玩knockoutjs并做一些简单的绑定/依赖绑定。 我的目标是根据另一个列表的值填充1个列表。 两者都是从ajax调用加载到我的asp.net webservice。 所以我有两个列表 然后我的JavaScript看起来像这样: $(function () { // creating the model var option = function (text, value) { this.text = text; this.value = value; } // creating the view model var searchModel = { availableMakes: ko.observableArray([]), availableModels: ko.observableArray([]), selectedMake: ko.observable(), selectedModel: ko.observable() } // adding in a dependentObservable to update the Models based […]