Merge pull request #67 from dpradeep/merge-20140827
[civicrm-core.git] / js / jquery / jquery.crmeditable.js
index f563f6d174ac6131e76e77c60f65ab12d87be8e9..bb86b2f65a5e6deb7f5bf68349ede18d74a78d80 100644 (file)
       el = this[0],
       ret = {},
       $row = this.first().closest('.crm-entity');
-    ret.entity = $row.data('entity') || $row[0].id.split('-')[0];
-    ret.id = $row.data('id') || $row[0].id.split('-')[1];
+      ret.entity = $row.data('entity') || $row[0].id.split('-')[0];
+      ret.id = $row.data('id') || $row[0].id.split('-')[1];
+      ret.action = $row.data('action') || 'setvalue';
+
     if (!ret.entity || !ret.id) {
       return false;
     }
@@ -41,7 +43,7 @@
           field: info.field,
           value: checked ? 1 : 0
         };
-        CRM.api(info.entity, 'setvalue', params, {
+        CRM.api(info.entity, info.action, params, {
           context: this,
           error: function(data) {
             editableSettings.error.call(this, info.entity, info.field, checked, data);
@@ -68,7 +70,7 @@
       },
       success: function(entity, field, value, data) {
         var $i = $(this);
-        CRM.alert('', ts('Saved'), 'success');
+        CRM.status(ts('Saved'));
         $i.removeClass('crm-editable-saving crm-error');
         $i.html(value);
       }
         var
           info = $i.crmEditableEntity(),
           params = {},
-          action = $i.data('action') || 'setvalue';
+          action = $i.data('action') || info.action;
         if (!info.field) {
           return false;
         }