Expand my Community achievements bar.

AEM Adaptive forms Table , how to find if its the last instance of the table using script in rule editor?

Avatar

Level 1

Hi all, I have AEM forms Table connected to Schema binding, The rows of table repeats as per the amount of items present in the schema, Is there any event , or technique i can use to trigger a specific script only at the last instance of the table row, and not when every row is getting generated? Any help ideas would be helpful.

thanks.

6 Replies

Avatar

Level 5

I think triggering your script from Table::ready:layout  

Avatar

Level 1

Thank you, but i should have mentioned this is Adaptive Form table where these rows are repeating. Thanks Again

Avatar

Level 5

Try triggering from "Table - Visibility" or a parent panel.

Avatar

Level 1

I tried executing from Table - Visibility event.  the script does get executed after the instances are created. But seems like Dom is not updated with these new instances.

On Table Visibility: Maybe below script can help explain the problem.

==============

//Event:visibility:

var insCnt = TableA.Row1.instanceManager.instanceCount; //Gives 5 Row 1 repeats 5 times via binding.

for (var i=0 ; i< insCnt ; i++)
{
var rowID = TableA.Row1.instanceManager.instances[i].id; // Works as id of ROw1 instance is available.
$("#"+rowID) // Cant find using Jquery, as Instance is not updated in the DOM ?
}

 

Can you have any way around this?

Regards,

 

Avatar

Level 5

I think that should work. Can you console.log that and see what you get?

What are you eventually trying to achieve?

Avatar

Level 1

this.instanceManager.instanceCount - used to determine total number of repeatable instances/rows

this.instanceIndex - used to fetch current row index#(typically starts from 0,1,2..)

 

if(this.instanceManager.instanceCount === this.instanceIndex+1)

{

//add specific script for the last instance/row

}