-
-
Save xavierzwirtz/1162e038ccf696a0ccf7b0524b291dce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
----first in script | |
var ShipViaDeliveryOptions = ko.observableArray(); | |
//var ShipViaDeliveryOptions = ko.observableArray(ShipViaDeliveryOption); | |
var updateShipViaDeliveryOptions = function() { | |
$BDSW.jsonfactory({ | |
method: 'CartUpdateShipViaDeliveryOptions', | |
data: { | |
'ShipViaCode': $cmbShipVia.val() | |
}, | |
success: function (data) { | |
// build your data like so | |
ShipViaDeliveryOptions.removeAll(); | |
_(data).each(function(item) { | |
var item = { | |
DeliveryOptionName: valueHere | |
DeliveryOptionDefault: valueHere | |
DeliveryOptionView: valueHere | |
} | |
ShipViaDeliveryOptions.push(item); | |
}); | |
} | |
}); | |
} | |
ko.applyBindings(data, $('#ShipViaDeliveryOptions')[0]); | |
----- then in webcall | |
<WebMethod(EnableSession:=True)> | |
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> | |
Public Function CartUpdateShipViaDeliveryOptions(ShipViaCode As String) As JObject | |
Try | |
Dim deliveryOptions = AppCon.Factory.ShipViaDeliveryOptionCollectionLoaded(ShipViaCode) | |
Dim oJSchema As New JSchema | |
'oJSchema.AddProperty("ID") | |
oJSchema.AddProperty("DeliveryOptionName") | |
oJSchema.AddProperty("DeliveryOptionDefault") | |
oJSchema.AddProperty("DeliveryOptionView") | |
Dim oJArray As JArray = JsonConvert.ToJArray(deliveryOptions, oJSchema) | |
Return New JObject( | |
New JProperty( | |
"DeliveryItems", oJArray | |
) | |
) | |
Catch excCartUpdateShipViaDeliveryOptions As Exception | |
Throw | |
End Try | |
End Function | |
--- then in html | |
<div id="ShipViaDeliveryOptions" class="row collapse" data-bind="visible: ShipViaDeliveryOptions.length > 0"> | |
<div class="large-3 small-3 columns"> | |
<span class="prefix">Accessorial Charges</span> | |
</div> | |
<!-- ko foreach: ShipViaDeliveryOptions --> | |
<div class="large-9 small-9 columns"> | |
<div class="row collapse"> | |
<div class="small-1 medium-1 columns"> | |
| |
</div> | |
<div class="small-1 medium-1 columns"> | |
<input type="checkbox" runat="server" id="ChkDeliveryOptionDefault" data-bind="checked: DeliveryOptionDefault" AutoPostBack="false"/> | |
</div> | |
<div class="small-7 medium-7 columns"> | |
<div data-bind="text: DeliveryOptionName"></div> | |
</div> | |
</div> | |
</div> | |
<!-- /ko --> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment