Skip to content

Instantly share code, notes, and snippets.

Created December 28, 2016 23:42
Show Gist options
  • Save anonymous/6b2186ffd1547055a236f40d50fc617c to your computer and use it in GitHub Desktop.
Save anonymous/6b2186ffd1547055a236f40d50fc617c to your computer and use it in GitHub Desktop.
----first in script
var ShipViaDeliveryOptions = {
DeliveryOptionName: ko.observable(),
DeliveryOptionDefault: ko.observable(),
DeliveryOptionView: ko.observable()
}
//var ShipViaDeliveryOptions = ko.observableArray(ShipViaDeliveryOption);
var updateShipViaDeliveryOptions = function() {
$BDSW.jsonfactory({
method: 'CartUpdateShipViaDeliveryOptions',
data: {
'ShipViaCode': $cmbShipVia.val()
},
success: function (data) {
ShipViaDeliveryOptions(data);
ko.applyBindings(data, $('#ShipViaDeliveryOptions')[0]);
}
});
}
//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">
&nbsp;
</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