this is a part of my cshtml code in NopCommerce:
new ColumnProperty(nameof(BusinessUnitCustomerModel.Approved))
{
Title = T("Admin.BusinessUnit.Customers.Fields.Approved").Text,
ClassName = NopColumnClassDefaults.CenterAll,
Render = new RenderSwitchButton("", T("Admin.BusinessUnit.Customers.Fields.ToggleApprove").Text)
{
OnClickFunctionName = "toggleApprovedCustomer",
OnLoadFunction = "toggleApprovedCustomerLoad"
},Data=nameof(BusinessUnitCustomerModel.CustomerBusinessUnitId)
},
I write a JS script wanna be loaded after the page loading is finished. This is my script code below:
<script asp-location="Footer">
$(document).ready(function () {
window.alert($('.switchbuttongrid').length())
})
function toggleApprovedCustomerLoad(elem, data) {
var postData = {
id: data
};
addAntiForgeryToken(postData);
$.ajax({
cache: false,
type: "POST",
url: "@(Url.Action("ToggleApprove", "BusinessUnit"))",
data: postData,
success: function (data, textStatus, jqXHR) {
updateTable('#businessunitCustomers-grid');
},
error: function (jqXHR, textStatus, errorThrown) {
alert(errorThrown);
}
});
}
</script>
Can somebody help me to solve this problem? (I need this script load after the page loading is done)