Qurel
@Qurel

Некорректно вызывается первый popup после клика на второй?

Есть 2 кнопки, при клике на которые вызываются разные модальные окна. Если сделал вызов второго модального окна, первое некорректно работает.
Функция вызова первого модального окна:
$(document.body).on('click', '.js-paid__buy', function()
    {
		var $button = $(this);
		var modal = $('.js-paid__buy-form');

		var modalPeriod = $(this).data('period') || $(this).data('days') || '';
        var modalPrice = $(this).data('price') || '';
        var modalTitle = $(this).data('title') || '';
        var modalManagerId = $(this).data('mid') || '';
        var dealsType = $(this).data('deals_type') || '';
        var name;

        $('.remodal-main', $remodal).html(modal.show());
		inst.open();


		$(document.body).on('click', '.remodal .js-modal__close', function () {
			inst.close();
		});

		if(modalPeriod && modalPrice){
            if (12 == dealsType) {
            	name = 'Количество публикаций';
            } else {
                name = 'Период оформления';
			}
            modal.find('.js-buy-information').html(`
				<div class="text_center font-120">
					<b>${name}:</b> ${modalPeriod}, 
					<b>цена:</b> ${modalPrice} грн.
					<input value="${modalPeriod}" name="period" type="hidden">
					<input value="${modalPrice}" name="price" type="hidden">
					<input value="${modalTitle}" name="title" type="hidden">
					<input value="${modalManagerId}" name="mid" type="hidden">
					<input value="${dealsType}" name="deals_type" type="hidden">
				</div>	
			`);
		}

		//notificationAdvertPopup (or notification) method is a global method to send POST message via ajax to /notification/send
		modal.find('form').validate({
			submitHandler: function(form) {
				var st = notificationAdvertPopup(
					$button.data('order_service'),
					$("input[name=email]", $(form)).val(),
					$("textarea[name=text]", $(form)).val(),
					$("input[name=name]", $(form)).val(),
					$("input[name=phone]", $(form)).val(),
                    modalPrice,
                    modalPeriod,
                    modalTitle,
                    modalManagerId,
                    dealsType
				);

				if(st) {
					inst.close();
					//$(form).inputsReset();
					if(lang==="ukr"){
						noty('Ваше повідомлення відправлено. Найближчим часом з Вами зв\'яжеться менеджер.', 'success', 10000);
					}else{
						noty('Ваше сообщение отправлено. В ближайшее время с Вами свяжется менеджер.', 'success', 10000);
					}
                }
			}
		});
	});

Функция вызова второго модального окна:
$(document.body).on('click', '.js-example', function()
    {
    	var $modal = $( $('#example_content').html() );
    	$modal.find('img').prop('src', $(this).data('img'));
	    $('.remodal-main', $remodal).html($modal);
	    inst.open();

        $(document.body).on('closed', '.remodal', function (e) {
            e.preventDefault();
            $("html, body").scrollTop(1300); //scroll to previous position after modal closed
        });

    });

Вот как выглядит повторный вызов первого модального окна, если перед его вызовом было вызвано второе:
5cd51fbcc2d90967803367.jpeg
Не вставляется .js-paid__buy-form, блок пустой:
5cd5201542cf3364836608.jpeg
  • Вопрос задан
  • 117 просмотров
Пригласить эксперта
Ваш ответ на вопрос

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

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