Skip to content

Instantly share code, notes, and snippets.

@Sentinel-7
Last active August 18, 2021 14:47
Show Gist options
  • Save Sentinel-7/daf16a70dab1703513fa94c5ce5aff95 to your computer and use it in GitHub Desktop.
Save Sentinel-7/daf16a70dab1703513fa94c5ce5aff95 to your computer and use it in GitHub Desktop.
Передаем title в форму
в чанке формы пишем
<div class="form-group">
<input type="text" name="product" value="[[!+fi.product]]" class="form-control" readonly="readonly">
</div>
JS вешаем на кнопку
{ignore}
<script>
$(document).ready(function() {
$('a.theme-btn.btn-style-five').on('click', function(){
$('input[name="product"]').val($(this).data('title'));
} );
});
</script>
{/ignore}
Сама кнопка
<a data-fancybox data-src="#quick_order" href="javascript:;" data-title="{$_modx->resource.pagetitle}" class="theme-btn btn-style-five">Заказать</a>
Передать заголовок
var textContent = $('button').data('title');
$('h2.a-popup__title').text(textContent);
======================================================================================
вариант 2
<div class="col-md-6 pprev">
<div class="pfon" style="background-image:url('{$serviceImg}')"></div>
<div class="category-service-item-text plink row">
<a href="{$uri}" class="ptitle2 pagetitle-services">{$pagetitle}</a>
<a class="ptitle2 pmore_link" href="{$uri}">Читать дальше</a>
{if $price}
<div class="ptitle">Цена: {$price} руб.</div>
{/if}
<div class="zapis-services-btn" data-toggle="modal" data-target="#zapisservices">Купить</div>
</div>
</div>
<script>
$('.zapis-services-btn').on('click', function () {
var parent = $(this).parent();
var taga = $(parent).find('.pagetitle-services');
$('#zapis-services-services').val($(taga).html());
$('#zapis-services-url').val("[[!++site_url]]" + $(taga).attr('href'));
$('#zapis-services-title').attr('href', $(taga).attr('href'));
$('#zapis-services-title').html($(taga).html());
});
</script>
в чанке ajaxform пишем
<a href="[[*uri]]" id="zapis-services-title" class="form_href-services">[[*longtitle:is=``:then=`[[*pagetitle]]`:else=`[[*longtitle]]`]]</a>
<div class="field-6">
<input id="zapis-services-services" name="zapis-services-services" type="hidden" value="[[*longtitle:is=``:then=`[[*pagetitle]]`:else=`[[*longtitle]]`]]">
<input id="zapis-services-url" name="zapis-services-url" type="hidden" value="[[!++site_url]][[*uri]]">
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment