Skip to content
Snippets Groups Projects
Commit 2d83d625 authored by mattwire's avatar mattwire
Browse files

Trigger recurStart on crmStripeBillingFormReloadComplete, store...

Trigger recurStart on crmStripeBillingFormReloadComplete, store #stripe-recurring-start-date block in javascript variable and remove/add as required
parent 658743a0
No related branches found
No related tags found
1 merge request!1246.5
......@@ -7,14 +7,19 @@
var scriptName = 'stripeRecurStart';
var recurSection = '.is_recur-section';
var recurMode = 'recur';
var stripeRecurringStartDateSection = null;
document.addEventListener('DOMContentLoaded', function() {
CRM.payment.debugging(scriptName, 'DOMContentLoaded');
$(document).on('crmStripeBillingFormReloadComplete', function() {
CRM.payment.debugging(scriptName, 'crmStripeBillingFormReloadComplete');
if (!$(recurSection).length) {
recurSection = '#allow_auto_renew';
recurMode = 'membership';
}
if ($('#stripe-recurring-start-date').length) {
stripeRecurringStartDateSection = $('#stripe-recurring-start-date');
}
if (!$(recurSection).length) {
// I'm not on the right kind of page, just remove the extra field
$('#stripe-recurring-start-date').remove();
......@@ -22,7 +27,7 @@
// Remove/insert the recur start date element just below the recur selections
$(recurSection + ' #stripe-recurring-start-date').remove();
$(recurSection).append($('#stripe-recurring-start-date'));
$(recurSection).append(stripeRecurringStartDateSection);
// It is hard to detect when changing memberships etc.
// So trigger on all input element changes on the form.
......@@ -40,7 +45,6 @@
toggleRecur();
inputOnChangeRunning = false;
}, 200);
toggleRecur();
});
// Trigger when we change the frequency unit selector (eg. month, year) on recur
$('select#frequency_unit').on('change', function() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment