From 6aa36518a927b831634e146dc534af4e9a5c13f0 Mon Sep 17 00:00:00 2001 From: Dan Schultz Date: Mon, 25 Apr 2011 16:23:14 -0700 Subject: [PATCH] scoping loadRequest function to entity that it's defined within --- src/mesh/model/associations/Association.as | 2 +- src/mesh/model/associations/AssociationCollection.as | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/mesh/model/associations/Association.as b/src/mesh/model/associations/Association.as index 4969ee1..257579e 100644 --- a/src/mesh/model/associations/Association.as +++ b/src/mesh/model/associations/Association.as @@ -110,7 +110,7 @@ package mesh.model.associations if (!isLoaded) { callback("beforeLoad"); - _loadRequest = definition.hasLoadRequest ? definition.loadRequest() : createLoadRequest(); + _loadRequest = definition.hasLoadRequest ? definition.loadRequest.apply(owner) : createLoadRequest(); _loadRequest.addHandler({ success:function():void { diff --git a/src/mesh/model/associations/AssociationCollection.as b/src/mesh/model/associations/AssociationCollection.as index e0b1445..e3aef3b 100644 --- a/src/mesh/model/associations/AssociationCollection.as +++ b/src/mesh/model/associations/AssociationCollection.as @@ -34,7 +34,7 @@ package mesh.model.associations object = []; afterLoad(loaded); - beforeAdd(populateInverseAssociation); + afterAdd(populateInverseAssociation); } /** @@ -204,6 +204,8 @@ package mesh.model.associations { if (definition.hasInverse) { if (entity.hasOwnProperty(definition.inverse)) { + // if the inverse relationship is an association, then we populate the inverse + // association's object. otherwise, we just set the property to the association's owner. if (entity[definition.inverse] is Association) { entity[definition.inverse].object = owner; } else { @@ -370,6 +372,10 @@ package mesh.model.associations value = value.toArray(); } + for each (var entity:Entity in value) { + callbackIfNotNull("beforeAdd", entity); + } + super.object = new ArrayCollection(value); if (_mirroredEntities == null) {