list.js: Cannot read property 'childNodes' of undefined

When attempting to create a List with no initial <li> elements in the DOM, List.js fails at this line.

Here is a small example (using jQuery):

$(function () {
    var options = {valueNames: ["name"]};
    var list = new List("list", options);

    $("#add-item").click(function () {
      list.add({name:"John"});
    });
});

Adding [] for the values argument of List’s constructor doesn’t help.

Reproduced on: Chrome 14.0.835.202 Safari 5.1.1 (7534.51.22)

About this issue

  • Original URL
  • State: closed
  • Created 13 years ago
  • Comments: 21 (3 by maintainers)

Most upvoted comments

Been using this plugin for 5 minutes and have already run into this catastrophic bug. 👎

@hughrawlinson @ryanbrodie @jefffriesen <ul id="exampleListUL"> should be <ul class="list">

@mynameistechno I know that it’s been long time since last big update but I’m currently working hard with v1.0.0 😁

Try giving the ul the classname ‘list’. This solved the problem for me.

Nah, the problem is that it needs to look like this or something:

<div id="my-list">
  <!-- .list has to be within #my-list -->
  <div class="list">
    <div><span class="item">...</span></div>
    ...
  </div>
</div>

It can’t read the content when a value name class is put on the item root element.

just add <ul class="list"></ul> In the div that you selected

example: `<div id="example-list">

    </div>`