This commit is contained in:
2023-10-05 19:29:12 +03:00
parent 01414ca4c6
commit 5fa470bd9c
3 changed files with 23 additions and 10 deletions

View File

@@ -1,16 +1,21 @@
page_iterator = 2
separator_iterator = 1
function load_routes (el) {
function load_routes (el,news=null) {
let number_last_route = el.id
let data_d = {
'from_el':parseInt(number_last_route) + 1,
'to_el':parseInt(number_last_route) + 11
}
let get_url = ""
let list = forloop_func_form(data_d,"get",get_url)
data_d = list[0]
get_url = list[1]
let url_ajax = "get_articles_block/"
if (!news){
let list = forloop_func_form(data_d,"get",get_url)
data_d = list[0]
get_url = list[1]
url_ajax = "routes/find_routes/"
}
let loader = document.querySelector(".loader_f_loading_routes")
loader.classList.toggle("show")
el.classList.toggle("hide")
@@ -25,7 +30,7 @@ function load_routes (el) {
$.ajax({
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
url: '/ru/routes/find_routes/',
url: `/ru/${url_ajax}`,
type: "POST",
// async: true,
cache: false,
@@ -36,8 +41,14 @@ function load_routes (el) {
success: function(data){
// new_el.parentNode.insertBefore(data.html, new_el.nextSibling);
let url_insert = ".page_routes_" + page_iterator
let place_ins = document.querySelector(url_insert)
//
// let url_insert = ".page_routes_" + pasge_iterator
// let place_ins = document.querySelector(url_insert)
//
let place_ins = el.parentNode.previousElementSibling.previousElementSibling
place_ins.innerHTML = data.html
let old_page_iterator = page_iterator
page_iterator++

View File

@@ -18,4 +18,5 @@
{% endif %}
{#<div>{{ art.text|safe }}</div>#}
{% endfor %}
</div>
</div>
<div class="clear_both"></div>

View File

@@ -37,12 +37,13 @@
{% if last_block == False %}
<div class="text-align-center w-68 f-r">
<button class="button-find-more-routes" id="25" onclick="load_routes(this)">{% trans "Показать ещё 10" %}</button>
{% csrf_token %}
<button class="button-find-more-routes" id="25" onclick="load_routes(this,'news')">{% trans "Показать ещё 10" %}</button>
<div class="width-100 text-align-center mb-10">
<img class="loader_f_loading_routes" src="{% static "img/svg/loader.svg" %}">
</div>
</div>
{% endif %}
{# boris edited end#}
{% endblock %}