Fix enableDisableApi to fire crmPopupFormSuccess event
[civicrm-core.git] / js / crm.livePage.js
index 4d241ef88e8505ee21dfa7ec0ba88732460fcd18..35c8b39312dd7cc3a333c4d5dc255b364798e929 100644 (file)
@@ -1,22 +1,12 @@
 // http://civicrm.org/licensing
 // Adds ajaxy behavior to a simple CiviCRM page
-cj(function($) {
+CRM.$(function($) {
+  var active = 'a.button, a.action-item:not(.crm-enable-disable), a.crm-popup';
   $('#crm-main-content-wrapper')
     // Widgetize the content area
     .crmSnippet()
     // Open action links in a popup
-    .off('click.crmLivePage')
-    .on('click.crmLivePage', 'a.button, a.action-item', function() {
-      // only follow real links not javascript buttons
-      if ($(this).attr('href') === '#' || $(this).attr('onclick') || $(this).hasClass('no-popup')) {
-        return;
-      }
-      CRM.loadForm($(this).attr('href'), {
-        openInline: 'a:not("[href=#], .no-popup")'
-      }).on('crmFormSuccess', function(e, data) {
-        // Refresh page when form completes
-        $('#crm-main-content-wrapper').crmSnippet('refresh');
-      });
-      return false;
-    });
+    .off('.crmLivePage')
+    .on('click.crmLivePage', active, CRM.popup)
+    .on('crmPopupFormSuccess.crmLivePage', active, CRM.refreshParent);
 });