question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Creating a dynamic table with a template fails in getElementsByClassName

See original GitHub issue

I’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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
AlexisTMcommented, Oct 21, 2016

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 😄

0reactions
lukeedcommented, Oct 21, 2016

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found