Merge pull request #3601 from atif-shaikh/CRM-14942
[civicrm-core.git] / templates / CRM / common / enableDisableApi.tpl
index 64f33e4aa136578f4d16c540ee52650c7c25da84..83a9964c39e27e9e75e596aba4c42a2f66d361ed 100644 (file)
@@ -1,8 +1,8 @@
 {*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -26,8 +26,8 @@
 {* handle common enable/disable actions *}
 {literal}
 <script type="text/javascript">
-  cj(function($) {
-    var $row, $table, info, enabled, fieldLabel;
+  CRM.$(function($) {
+    var $row, info, enabled, fieldLabel;
 
     function successMsg() {
       {/literal} {* client-side variable substitutions in smarty are AWKWARD! *}
     }
 
     function refresh() {
-      // Call native refresh method on ajax datatables
-      if ($.fn.DataTable.fnIsDataTable($table[0]) && $table.dataTable().fnSettings().sAjaxSource) {
-        $.each($.fn.dataTable.fnTables(), function() {
-          $(this).dataTable().fnSettings().sAjaxSource && $(this).unblock().dataTable().fnDraw();
-        });
-      }
-      // Otherwise refresh the content area using crmSnippet
-      else {
-        $row.closest('.crm-ajax-container, #crm-main-content-wrapper').crmSnippet().crmSnippet('refresh');
-      }
+      CRM.refreshParent($row);
     }
 
     function save() {
-      $table = $row.closest('table');
-      $table.block();
+      $row.closest('table').block();
       CRM.api3(info.entity, 'setvalue', {id: info.id, field: 'is_active', value: enabled ? 0 : 1}, {success: successMsg}).done(refresh);
       if (enabled) {
         $(this).dialog('close');