remotes/1693045480750635534/spooky-22
kek7198 2021-12-05 12:03:26 -06:00
parent 1e40128bdf
commit b59d7f2b30
1 changed files with 6 additions and 3 deletions

View File

@ -692,7 +692,8 @@
{% if offset %} {% if offset %}
<script defer> <script defer>
function loadMore(id) { function loadMore(id, btn) {
const btn = document.getElementById(btn)
const el = document.getElementById(id) const el = document.getElementById(id)
const form = new FormData(); const form = new FormData();
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();
@ -702,13 +703,15 @@
xhr.onload=function(){ xhr.onload=function(){
if (xhr.status==200) { if (xhr.status==200) {
el.innerHTML = xhr.response; el.innerHTML = xhr.response;
btn.classList.toggle('hidden');
} else {
btn.disabled = false;
} }
el.classList.toggle('hidden');
} }
xhr.send(form) xhr.send(form)
} }
</script> </script>
<button class="mt-2 w-full btn btn-gray" onclick="loadMore('comment-section'); this.disabled = true;"> <button class="mt-2 w-full btn btn-gray" id="load-more-button" onclick="loadMore('comment-section', this.id); this.disabled = true;">
Load more comments Load more comments
</button> </button>
{% endif %} {% endif %}