Home
TeamSite
TeamSite, LiveSite and OpenDeploy
Need help deleting multiple container instances with onReplicantDelete
System
I have a form with a container that is only allowed to have 1 or 4 instances (never 2 or 3).
If the user clicks to add an instance, I used the onReplicantAdded and it adds three. Easy enough.
Now, if the user clicks to delete instance 1 or 2 or 3 or 4, I tried to use the onReplicantDelete to delete instances 2, 3 and 4 (regardless if they clicks on 1 or 2 or 3 or 4). But, this enters me into an infinite loop. Best guess is that the function is getting retriggered when I'm using .deleteInstance within the function. But, I don't know how to get around that.
I'm sure someone has had this scenario before. Is there any advice you can give me to help me figure out how to avoid this infinite loop?
Here's a very simple code layout:
function init() {
IWEventRegistry.addItemHandler("/featured_products_banner/product","onReplicantDelete",fnHandleProdLinkDelete);
}
function fnHandleProdLinkDelete() {
IWDatacapture.getItem("featured_products_banner/product").deleteInstance(2);
IWDatacapture.getItem("featured_products_banner/product").deleteInstance(3);
IWDatacapture.getItem("featured_products_banner/product").deleteInstance(4);
return false;
}
I'm new to TeamSite FormAPI so I apologize if this is a common question.
Find more posts tagged with
Comments
There are no comments yet