function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Tejender Mohan 9Tejender Mohan 9 

Aura iteration does not update the View after array Update?

My lightning component's controller has an array named newResources and using aura:iteration to show a table based on the values in it. There is a method in js "removeNewResourceColumn" which removes one element from that array and then the aura:itration updates the view with one less row but when the method removes the last element of array the aura iteration view is not getting updated.

E.g. If I have 8 records in the array then the table will show 8 rows. If removeNewResourceColumn removes 6th element the table will show 7 records but if removeNewResourceColumn removes 8th element the table still shows 8 records.
Has anyone ever faced this problem?
Tejender Mohan 9Tejender Mohan 9
Here is the code snippet
Lightning Component
Here is the code snippet

Lightning Component

    <table class="slds-table slds-table_bordered slds-table_striped">
        <aura:iteration items="{!v.newResources}" var="newResource" indexVar="index">
            <td data-label="FirstName">
                <div class="slds-truncate">
                    <div class="slds-form-element__control" style="width:95%">
                        <div aura:id="nameField" class="slds-show">
                            <ui:inputText class="slds-input" value="{!newResource.FirstName}" placeholder="" disabled=""/>
            //It has more columns like first name

var RecordIndexStr = event.getSource().get("v.value");
var RecordIndexInt = parseInt(RecordIndexStr);
var newResources = component.get("v.newResources");

newResources.splice(RecordIndexInt, 1);


Jose Aguilar 1Jose Aguilar 1
Have you fixed this issue?

I am having the exact same problem and don't know how to fix it.