I have pending updates .
I have two components.
The first is a list that is simply implemented as a div with foreach data binding:
<div class="list-people" data-bind="foreach: { data: people, afterRender: afterRenderPeople }">
</div>
Second list item:
<div class="listitem-person">
<span data-bind="text: Name"></span>
</div>
afterRendercalled for each item in foreach.
My afterRenderPersonfunction is quite simple:
public afterRenderPerson = (elements: any[], data: Person) => {
let top = $(element[0]).offset().top;
scrollTo(top);
};
The problem is that when called, the afterRenderPersonsubcomponent listitem-personis not yet displayed.
Which means that the array of elements passed in afterRenderPersonhas 4 nodes:
- Node text containing
\ni.e. new line. - Comment node containing
<!-- ko component: { name: "listitem-person", params: { person: $data } } -->. - Comment node containing
<!-- /ko -->. - Node text containing
\ni.e. new line.
top, , , , .