dlsso dlsso - 4 months ago 15
Javascript Question

How to know when iron-list is finished creating html

Background



I am creating a a polymer iron-list and populating the list by setting the
items
property directly, like so:
document.getElementById('itemsList').items = data;


When user changes category I change value of
items
in the above manner (retrieved with ajax). This works perfectly, but I now need to change the options in a
select
depending on my list category. I was able to do this using templating but it's cumbersome and may not even work later when the options need to be dynamic.

I would like to simply hide certain options with JavaScript but the
select
I want to manipulate is not present immediately after doing
.items = data
. I need a callback or some other way to detect when
iron-list
is done inserting HTML.

Research



I looked through the documentation and couldn't find any references to callbacks or events other than
iron-resize
, and that doesn't look helpful.

I could potentially figure it out by listening
DOMNodeInserted
events but that's probably worse than the solution I've already got.

A
setTimeout
would also work, but is also a bad solution.

From miyamoto: I could check
_itemsRendered
on iron-list which gets set to true, but I would probably need to do
setInterval
to check, also bad.

Question



Is there a callback of any sort to let me know when
iron-list
is finished creating HTML? Failing that maybe an event or something else I could use to know when it's done?

Answer

We are currently trying to go a different route, but if anyone else needs to accomplish this it looks like the dom-change event should tell you.

Comments