<div class="address-grid">
@foreach (var item in Model.ExistingAddresses)
{
<div class="address-item">
<button type="button" class="button-1 select-billing-address-button" onclick="selectBillingAddress@(item.Id)()">@T("Checkout.BillToThisAddress")</button>
<script asp-location="Footer">
function selectBillingAddress@(item.Id)() {
if ($('#@Html.IdFor(model => model.ShipToSameAddress)')
.is(':checked')) {
setLocation(
'@Html.Raw(Url.RouteUrl("CheckoutSelectBillingAddress", new {addressId = item.Id, shipToSameAddress = "true"}))');
} else {
setLocation(
'@Url.RouteUrl("CheckoutSelectBillingAddress", new {addressId = item.Id})');
}
}
</script>
</div>
</div>
}
</div>
因为该函数是动态构建的,所以我无法描述它。我想做的就是在调用我的路线之前检查一些条件。