Spaces:
Running
Running
Update script.js
Browse files
script.js
CHANGED
|
@@ -125,9 +125,14 @@ function initializeCart() {
|
|
| 125 |
const addToCartButtons = document.querySelectorAll('.add-to-cart-btn');
|
| 126 |
addToCartButtons.forEach(button => {
|
| 127 |
button.addEventListener('click', (e) => {
|
| 128 |
-
e.preventDefault(); // Предотвращаем
|
|
|
|
|
|
|
|
|
|
| 129 |
const serviceCard = button.closest('.service-card');
|
| 130 |
const serviceName = serviceCard.getAttribute('data-service');
|
|
|
|
|
|
|
| 131 |
if (serviceName && !cart.includes(serviceName)) {
|
| 132 |
cart.push(serviceName);
|
| 133 |
updateCart();
|
|
@@ -140,6 +145,14 @@ function initializeCart() {
|
|
| 140 |
});
|
| 141 |
});
|
| 142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
// Открытие/закрытие модального окна корзины
|
| 144 |
const cartIcon = document.getElementById('cartIcon');
|
| 145 |
const cartModal = document.getElementById('cartModal');
|
|
|
|
| 125 |
const addToCartButtons = document.querySelectorAll('.add-to-cart-btn');
|
| 126 |
addToCartButtons.forEach(button => {
|
| 127 |
button.addEventListener('click', (e) => {
|
| 128 |
+
e.preventDefault(); // Предотвращаем стандартное поведение
|
| 129 |
+
e.stopPropagation(); // Останавливаем всплытие события до карточки
|
| 130 |
+
console.log('Кнопка "Добавить в корзину" нажата'); // Отладка
|
| 131 |
+
|
| 132 |
const serviceCard = button.closest('.service-card');
|
| 133 |
const serviceName = serviceCard.getAttribute('data-service');
|
| 134 |
+
console.log('Услуга:', serviceName); // Отладка
|
| 135 |
+
|
| 136 |
if (serviceName && !cart.includes(serviceName)) {
|
| 137 |
cart.push(serviceName);
|
| 138 |
updateCart();
|
|
|
|
| 145 |
});
|
| 146 |
});
|
| 147 |
|
| 148 |
+
// Убедимся, что карточка не перехватывает клик
|
| 149 |
+
const serviceCards = document.querySelectorAll('.service-card');
|
| 150 |
+
serviceCards.forEach(card => {
|
| 151 |
+
card.addEventListener('click', (e) => {
|
| 152 |
+
console.log('Клик по карточке (должно игнорироваться)'); // Отладка
|
| 153 |
+
});
|
| 154 |
+
});
|
| 155 |
+
|
| 156 |
// Открытие/закрытие модального окна корзины
|
| 157 |
const cartIcon = document.getElementById('cartIcon');
|
| 158 |
const cartModal = document.getElementById('cartModal');
|