PaymentProcessor - Use ajax refresh
authorColeman Watts <coleman@civicrm.org>
Mon, 6 Feb 2023 17:02:09 +0000 (12:02 -0500)
committerColeman Watts <coleman@civicrm.org>
Mon, 6 Feb 2023 17:02:09 +0000 (12:02 -0500)
CRM/Admin/Form/PaymentProcessor.php
templates/CRM/Admin/Form/PaymentProcessor.tpl

index 2e6a3b99d11093884073dc6140cd8815cb032e1f..014727e76b03fee3636478b829f2ae325a915f04 100644 (file)
@@ -217,8 +217,7 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form {
       'payment_processor_type_id',
       ts('Payment Processor Type'),
       CRM_Financial_BAO_PaymentProcessor::buildOptions('payment_processor_type_id'),
-      TRUE,
-      ['onchange' => "reload(true)"]
+      TRUE
     );
 
     // Financial Account of account type asset CRM-11515
index 28827b440979d4156001877ab4fd5a521427db62..91e3ef405b205f19455c4db5518a6085ba355ff2 100644 (file)
 {if $action eq 1  or $action eq 2}
   <script type="text/javascript">
   {literal}
-    function reload(refresh) {
-      var paymentProcessorType = cj("#payment_processor_type_id");
-      var url = {/literal}"{$refreshURL}"{literal} + "&pp=" + paymentProcessorType.val();
-      paymentProcessorType.closest('form').attr('data-warn-changes', 'false');
-      window.location.href = url;
-    }
+    CRM.$(function($) {
+      $('#payment_processor_type_id').change(function() {
+        var url = {/literal}"{$refreshURL}"{literal} + "&pp=" + $(this).val();
+        $(this).closest('form').attr('data-warn-changes', 'false')
+          // Ajax refresh (works in a popup or full-screen)
+          .closest('.crm-ajax-container, #crm-main-content-wrapper')
+          .crmSnippet({url: url}).crmSnippet('refresh');
+      });
+    });
   {/literal}
   </script>