Добавил ссылки на продукты
This commit is contained in:
parent
d4967bc4e5
commit
afe0936b3e
@ -288,3 +288,7 @@
|
||||
align-items: flex-start;
|
||||
}
|
||||
}
|
||||
|
||||
.product-card {
|
||||
cursor: pointer;
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
{% extends 'programmer/base.html' %}
|
||||
{% load static %}
|
||||
{% load django_bootstrap5 %}
|
||||
|
||||
{% block extra_css %}
|
||||
{# Единый файл для CKEditor-контента (общий с блогом) #}
|
||||
@ -38,7 +39,7 @@
|
||||
{# ===== Сетка продуктов ===== #}
|
||||
<div class="products-grid">
|
||||
{% for product in products %}
|
||||
<div class="product-card">
|
||||
<div class="product-card" data-url="{{ product.get_absolute_url }}">
|
||||
{% if product.image %}
|
||||
<img src="{{ product.image.url }}" alt="{{ product.title }}" class="product-image" loading="lazy">
|
||||
{% else %}
|
||||
@ -85,3 +86,23 @@
|
||||
|
||||
{% include 'products/includes/pagination.html' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_js %}
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const cards = document.querySelectorAll('.product-card');
|
||||
cards.forEach(card => {
|
||||
const url = card.dataset.url;
|
||||
if (!url) return;
|
||||
|
||||
card.addEventListener('click', function(e) {
|
||||
// Если клик был по ссылке, кнопке или любому элементу с data-no-link
|
||||
const target = e.target.closest('a, button, .no-link');
|
||||
if (target) return;
|
||||
|
||||
window.location.href = url;
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user