Вопрос по JS как закрыть окно после добавление товара в корзину?

Друзья выручайте. Есть сайт. На страницах категорий есть товары, при клике на кнопку "В корзину" всплывает окно куда загружается iframe, там дальше всё просто вводишь количество и нажимаешь купить, ajax-сом товар отправляется в корзину. Теперь вопрос, как после отправки товара в корзину закрыть модальное окно? windows.close() не работает, я пытался повесить на функцию click, но id окна я не могу найти. Так же пытался симитировать нажатие на крестик закрытия но у этой кнопки тоже нет id. Помогите кто может.

Вот сайт на котором пытаюсь сделать.
led-elektro.ru/kabelno-provodnikovaya-produkciya-/...
  • Вопрос задан
  • 271 просмотр
Решения вопроса 1
skbeloff
@skbeloff Автор вопроса
Не силён в JS поэтому и спросил. Ну всё равно не срабатывает. Вот листинг.

<script type="text/javascript"><!--
$('select[name=\'recurring_id\'], input[name="quantity"]').change(function(){
	$.ajax({
		url: 'index.php?route=product/product/getRecurringDescription',
		type: 'post',
		data: $('input[name=\'product_id\'], input[name=\'quantity\'], select[name=\'recurring_id\']'),
		dataType: 'json',
		beforeSend: function() {
			$('#recurring-description').html('');
		},
		success: function(json) {
			$('.alert, .text-danger').remove();

			if (json['success']) {
				$('#recurring-description').html(json['success']);
			}
		}
	});
});
//--></script>
<script type="text/javascript"><!--
$('#button-cart').on('click', function() {
	$.ajax({
		url: 'index.php?route=checkout/cart/add',
		type: 'post',
		data: $('#product input[type=\'text\'], #product input[type=\'hidden\'], #product input[type=\'radio\']:checked, #product input[type=\'checkbox\']:checked, #product select, #product textarea'),
		dataType: 'json',
		beforeSend: function() {
			$('#button-cart').button('loading');
		},
		complete: function() {
			$('#button-cart').button('reset');
		},
		success: function(json) {
			$('.alert, .text-danger').remove();
			$('.form-group').removeClass('has-error');

			if (json['error']) {
                <?php if ($this->journal2->settings->get('quickview_product_options') !== '1'): ?>
                top.location = '<?php echo str_replace('&amp;', '&', $this->url->link('product/product', 'product_id=' . $product_id)); ?>';
                return;
                <?php endif; ?>
				if (json['error']['option']) {
					for (i in json['error']['option']) {
						var element = $('#input-option' + i.replace('_', '-'));

						if (element.parent().hasClass('input-group')) {
							element.parent().after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
						} else {
							element.after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
						}
					}
				}

				if (json['error']['recurring']) {
					$('select[name=\'recurring_id\']').after('<div class="text-danger">' + json['error']['recurring'] + '</div>');
				}

				// Highlight any found errors
				$('.text-danger').parent().addClass('has-error');
			}

			if (json['success']) {
                if (!parent.Journal.showNotification(json['success'], json['image'])) {
                    $('.breadcrumb').after('<div class="alert alert-success success">' + json['success'] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>');
                }

				parent.$('#cart-total').html(json['total']);

				$('html, body').animate({ scrollTop: 0 }, 'slow');

                parent.$('#cart ul').load('index.php?route=common/cart/info ul li');
                
			}
		}
	});
});
Ответ написан
Пригласить эксперта
Ответы на вопрос 1
Stalker_RED
@Stalker_RED
А кроме как по id вы не знаете способов найти элемент?
document.querySelector('.mfp-close').click()
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы