This is what worked for me. Notice the switch statment to prevent event bubbling.
function msoxd_my_Location::OnAfterChange(eventObj)
{
if (eventObj.IsUndoRedo)
{
return;
}
switch(eventObj.Operation)
{
case "Delete":
restoreRepeatingTable("group2_297");
break;
case "Insert":
if (eventObj.NewValue != "")
{
fillPlantNotificationList();
}
break;
default:
break;
}
}
function restoreRepeatingTable(cXmlToEdit)
{
XDocument.View.ExecuteAction("xCollection::removeAll", cXmlToEdit);
XDocument.View.ExecuteAction("xCollection::insert", cXmlToEdit);
}
function fillPlantNotificationList()
{
var oPnlItem = me.selectSingleNode("//my:PnlItem");
var oPnl = me.selectSingleNode("//my:PlantNotificationList");
var cLocation = me.selectSingleNode("//my:Location").text;
var oContacts = XDocument.DataObjects("Workflow").DOM.selectNodes("//dfs:Workflow[@Location='" + cLocation + "']");
if (oContacts)
{
for (var i = 0; i < oContacts.length; i++)
{
var oNewItem = oPnlItem.cloneNode(true);
oNewItem.selectSingleNode("my:PnlName").text = oContacts.item(i).selectSingleNode("@First_Name").text + " " + oContacts.item(i).selectSingleNode("@Last_Name").text + "";
oNewItem.selectSingleNode("my:PnlEmail").text = (address = oContacts.item(i).selectSingleNode("@E-mail_Address"))? address.text: "";
oNewItem.selectSingleNode("my:PnlPhone").text = (phone = oContacts.item(i).selectSingleNode("@Business_Phone"))? phone.text: "";
oPnl.insertBefore(oNewItem, oPnlItem);
}
}
}