Add Loading when click submit

This commit is contained in:
Ibnu Maksum 2024-02-22 11:41:55 +07:00
parent cee6f8949c
commit 8728af4332
No known key found for this signature in database
GPG key ID: 7FC82848810579E5
2 changed files with 52 additions and 3 deletions

View file

@ -21,10 +21,32 @@
<script>
$(document).ready(function() {
$('.select2').select2({theme: "bootstrap"});
});
$(document).ready(function() {
$('.select2tag').select2({theme: "bootstrap", tags: true});
var listAtts = document.querySelectorAll(`button[type="submit"]`);
listAtts.forEach(function(el) {
if (el.addEventListener) { // all browsers except IE before version 9
el.addEventListener("click", function() {
$(this).html(
`<span class="glyphicon glyphicon-refresh" role="status" aria-hidden="true"></span>`
);
setTimeout(() => {
$(this).prop("disabled", true);
}, 100);
}, false);
} else {
if (el.attachEvent) { // IE before version 9
el.attachEvent("click", function() {
$(this).html(
`<span class="glyphicon glyphicon-refresh" role="status" aria-hidden="true"></span>`
);
setTimeout(() => {
$(this).prop("disabled", true);
}, 100);
});
}
}
});
});
var listAtts = document.querySelectorAll(`[api-get-text]`);

View file

@ -79,6 +79,33 @@
el.innerHTML = data;
});
});
$(document).ready(function() {
var listAtts = document.querySelectorAll(`button[type="submit"]`);
listAtts.forEach(function(el) {
if (el.addEventListener) { // all browsers except IE before version 9
el.addEventListener("click", function() {
$(this).html(
`<span class="glyphicon glyphicon-refresh" role="status" aria-hidden="true"></span>`
);
setTimeout(() => {
$(this).prop("disabled", true);
}, 100);
}, false);
} else {
if (el.attachEvent) { // IE before version 9
el.attachEvent("click", function() {
$(this).html(
`<span class="glyphicon glyphicon-refresh" role="status" aria-hidden="true"></span>`
);
setTimeout(() => {
$(this).prop("disabled", true);
}, 100);
});
}
}
});
});
</script>
{/literal}