Creating a dynamic table with a template fails in getElementsByClassName
See original GitHub issueI’m getting
Uncaught TypeError: Cannot read property 'getElementsByClassName' of null list.js:1111
when creating a List using an empty
<table><tbody class="list"></tbody></table>
as the List’s container.
The error appears not at the first call to getElementsByClass, but at the second, when it’s setting up the template.
Very simple pen in http://codepen.io/fearless_fool/pen/eZyEJm?editors=1111, modeled after http://codepen.io/javve/pen/oEezp – the only difference is that there’s no pre-defined entries, and it uses an item:
template.
FWIW, I’m using Chrome Version 49.0.2623.110 (64-bit).
Can you reproduce this? Is there a workaround?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Why is getElementsByClassName not working for dynamically ...
seems like you haven't actually attached your newly created element into the document.
Read more >HTML DOM Element getElementsByClassName() - W3Schools
Well organized and easy to understand Web building tutorials with lots of examples of how ... The getElementsByClassName() method returns a NodeList object....
Read more >Handling dynamically created HTML in JavaScript - Medium
Handling dynamically created HTML in JavaScript. TL,DR. Where you can, use events that bubble and attach elements to the document object. You can...
Read more >From Vanilla JS to Vue.js: A guide to Vue essentials
Vue.js is a framework for building web applications. ... I used micro-template because the table will contain dynamic data and I want a...
Read more >NoErrorObjectAvailable Script error. when selecting value ...
please use this.template.querySelector(".type1") instead of document.getElementsByClassName('type1') using this is not a best practice.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It is also to show the problem is still active and the PR is needed. I’ll manually fix it from your repo. Thanks for the PR @lukeed 😄
@AlexisTM I have a PR (#412) open for months (!) now that fixes it. Check the commit if you want to manually apply it to your local copy.