Files
FSI.BT.IR.Organization/scr/FSI.BT.IR.Organization.Web/wwwroot/js/site.js
2024-10-25 13:35:06 +02:00

104 lines
2.7 KiB
JavaScript

// Write your JavaScript code.
// Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
// for details on configuring this project to bundle and minify static web assets.
// Write your JavaScript code.
showInPopup = (url, title) => {
$.ajax({
type: "GET",
url: url,
success: function (res) {
$("#form-modal .modal-body").html(res);
$("#form-modal .modal-title").html(title);
$("#form-modal").modal("show");
}
})
$(document).on("shown.bs.modal", "#form-modal", function () {
$("#ctrlToFocus").focus();
});
}
jQueryAjaxPost = form => {
try {
$.ajax({
type: 'POST',
url: form.action,
data: new FormData(form),
contentType: false,
processData: false,
success: function (res) {
if (res.isValid) {
$("#form-modal .modal-body").html('');
$("#form-modal .modal-title").html('');
$("#form-modal").modal("hide");
$("#view-all").serialize();
$("#view-all").html(res.html);
$("example").DataTable().ajax.reload();
}
else
$("#form-modal .modal-body").html(res.html);
},
error: function (err) {
console.log(err)
}
})
//to prevent default form submit event
return false;
} catch (ex) {
console.log(ex)
}
}
jQueryAjaxDelete = form => {
if (confirm('Soll der Datensatz gelöscht werden?')) {
try {
$.ajax({
type: 'POST',
url: form.action,
data: new FormData(form),
contentType: false,
processData: false,
success: function (res) {
$('#view-all').html(res.html);
},
error: function (err) {
console.log(err)
}
})
} catch (ex) {
console.log(ex)
}
}
//prevent default form submit event
return false;
}
jQueryAjaxUpdate = form => {
try {
$.ajax({
type: 'POST',
url: form.action,
data: new FormData(form),
contentType: false,
processData: false,
success: function (res) {
$('#view-all').html(res.html);
},
error: function (err) {
console.log(err)
}
})
} catch (ex) {
console.log(ex)
}
//prevent default form submit event
return false;
}