This commit is contained in:
SBD
2023-11-28 16:15:59 +03:00
parent 9cd6eaf060
commit 3cf374c755
2 changed files with 9 additions and 4 deletions

View File

@@ -29,10 +29,14 @@ function sendWidthAjax () {
return data return data
} }
function renderContent () { function renderContent (el=null) {
let data = sendWidthAjax() let data = sendWidthAjax()
let section_button = document.querySelector(".section_btn") if (!el) {
data['section_url'] = section_button.dataset['url'] let section_button = document.querySelector(".section_btn")
data['section_url'] = section_button.dataset['url']
} else {
data['section_url'] = el.dataset['url']
}
$.ajax({ $.ajax({
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() }, headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
url: '/get_content_for_section/', url: '/get_content_for_section/',
@@ -79,6 +83,7 @@ function replaceHrefOnOnclick () {
str = str.replace(str_f_replace,'') str = str.replace(str_f_replace,'')
str = str.replace('"target="_blank""','') str = str.replace('"target="_blank""','')
cur_el.outerHTML = str cur_el.outerHTML = str
cur_el.setAttribute("onclick",`renderContent(this)`)
} }
i++ i++
}) })

View File

@@ -2,7 +2,7 @@
<div class="container_sections_buttons"> <div class="container_sections_buttons">
<div class="cut-width container_content_sections_buttons"> <div class="cut-width container_content_sections_buttons">
{% for section in sections %} {% for section in sections %}
<a href="{% url 'section_page' section.url %}" target="_blank" class="section_btn {% if section == cur_section or page == section %}open{% else %}close{% endif %} standart_txt pointer" data-url="{{ section.url }}"> <a href="{% url 'section_page' section.url %}" class="section_btn {% if section == cur_section or page == section %}open{% else %}close{% endif %} standart_txt pointer" data-url="{{ section.url }}">
<div class="txt_section standart_txt">{{ section.name }}</div> <div class="txt_section standart_txt">{{ section.name }}</div>
</a> </a>
{% endfor %} {% endfor %}