I’ve been having trouble debugging this problem that I’ve run into, because no errors are being logged into the console. I would really appreciate the if someone could help point me in the right direction.
I created a helper function to create a series of labels and checkboxes to filter search dynamically from a schema because it’s cool and I was too lazy to type it all out and change it every time i needed to change the schema. Each checkbox has a label “filters”.
end result for one:
<label class="filters" for="products" draggable="true">Products</label>
<input class="filters" type="checkbox" id="products">
I have an event that is supposed to fire every time one of those checkboxes are clicked.
... do stuff here ...
to help debug I put an event handler to fire on every click, and log the instance, the template itself, and
Under normal conditions this instance.findAll() returns an array with every html element with the class “filters”.
document.getElementsByClassName always finds it.
the steps I take to reproduce this (in general, I’ll try to set up a reproduction repo later):
- submit form from aldeed:autoform
- toggle over to the search page. (again I was lazy and put this all in one template)
- switch search mode to this class of item (set by a radio group tracked by a reactivar)
- enter search
before step 3 filters are not attached to the instance even if rendered
on step 3 the template.instance().findAll briefly finds the full list of filters.I believe the helper runs once on step 3
on step 4 the filters are no longer found by template.instance().findAll
sorry for the long post any help is appreciated
TL;DR: on occasion dynamically generated elements returned from a helper function aren’t attached to the template instance.