Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lpc_template.queue.refreshForm = function ($self) {
- console.log(33)
- const $refreshButton = $('.lpc-refresh-form');
- if (!$refreshButton.length) {
- return;
- }
- const href = $refreshButton.attr('href');
- const popupMatch = href?.match(/popup:_lp_block_(\d+)/);
- console.log(popupMatch)
- if (!popupMatch) {
- return;
- }
- console.log(href)
- const popupId = popupMatch[1];
- const $popupElement = $(`[data-block-id="${popupId}"]`);
- if (!$popupElement.length) {
- return;
- }
- const $form = $popupElement.find('.lp-form-tpl');
- if (!$form.length) {
- console.log('❌ Форма не найдена внутри попапа');
- return;
- }
- const apiUrl = $form.attr('data-lpc-api-url');
- console.log(apiUrl);
- $refreshButton.off('click.refreshForm');
- $refreshButton.on('click.refreshForm', function (e) {
- const $form2 = $popupElement.find('.lp-form-tpl');
- // проверяешь есть ли успешно отправленнная форма, только потом тянешь аяксом форму, если уже отправляли форму, которая без аякса
- e.preventDefault();
- console.log(5553)
- $.ajax({
- url: apiUrl,
- dataType: 'json',
- success: function (response) {
- if (!response.result.error) {
- let htmlForm = response.result.html;
- $form2.replaceWith(htmlForm);
- console.log(34343434)
- s3LP.initForms($('#_lp_block_372266709'));
- }
- }
- });
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement