afterRender for
custom post processing logic in the DOM elements created by your templates
BUT, unfortunately, it is called after your template is ready (applied to the DOM), but it is not yet inserted into the html.
If you use foreach, the knockout will call an afterRender callback for each element added to the observable Array
but if it will also be called once, if you pass data to the template.
KO allows you to give afterAdd and / or beforeRemove callbacks to manipulate the added / removed DOM elements in a custom way
therefore, they will be called for each added / deleted item in the observed array. When they are called, your DOM is ready, so you will no longer hide, but these callbacks are only called when the main observable array changes.
<div data-bind="template: { name: 'tpl', foreach: a, afterAdd: sparkie }"></div>
rucsi source share