CrmAttachment - Fix bug wherein multiple CrmAttachments mix up their targets.
authorTim Otten <totten@civicrm.org>
Sun, 14 Dec 2014 08:42:31 +0000 (00:42 -0800)
committerTim Otten <totten@civicrm.org>
Sun, 14 Dec 2014 22:55:40 +0000 (14:55 -0800)
js/angular-crmAttachment.js

index 07578cbd2a7781620fad3d5202ea1dc440b1ec81..b9957c831cf9cb68e422258663bf613e4ccba5cd 100644 (file)
@@ -8,12 +8,10 @@
 
   // crmAttachment manages the list of files which are attached to a given entity
   angular.module('crmAttachment').factory('CrmAttachments', function (crmApi, crmStatus, FileUploader, $q) {
-    var _target;
-
     // @param target an Object(entity_table:'',entity_id:'') or function which generates an object
     function CrmAttachments(target) {
-      _target = target;
       var crmAttachments = this;
+      this._target = target;
       this.files = [];
       this.uploader = new FileUploader({
         url: CRM.url('civicrm/ajax/attachment'),
@@ -37,7 +35,7 @@
     angular.extend(CrmAttachments.prototype, {
       // @return Object(entity_table:'',entity_id:'')
       getTarget: function () {
-        return (angular.isFunction(_target) ? _target() : _target);
+        return (angular.isFunction(this._target) ? this._target() : this._target);
       },
       // @return Promise<Attachment>
       load: function load() {