Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List.JS - Cannot read property 'childNodes' of undefined

I cannot seem to figure this out. I've already tried $(document).ready and still doesn't work for me. I've also tried making a for loop specifically for these two value names to save the results to a var and pass it in that way. I've also tried putting the input with the class and id with search inside of the parent div and outside. Essentially like it in the nav bar. Using list.js & knockout.js btw. Im getting my venues using an ajax request using foursquares api.

JS:

        var options = {
        valueNames: ['name', 'category']
    };

    var userList = new List('search', options);

HTML:

<body>
<nav>
    <h1 class="formattedH1">Downtown SA,TX</h1>
    <span>
      <input type="search" placeholder="Search" class="search" id="search">
      <input type="button" class="sort searchButton" value="List"></input>
    </span>
</nav>
<div id="map" class="map"></div>
<div class="list">
    <input type="search" placeholder="Search" class="search" id="search">
    <h1>My Top 5</h1>
    <!-- Square card -->
    <div class="card" id="favViewModel" data-bind="foreach: favList">
        <div class="expand">
            <h2 class="venueName" data-bind="text:name"></h2>
        </div>
        <div class="cardSupport" data-bind="attr: {src: image()}">
        </div>
        <div class="cardSupport" data-bind="text:address">
        </div>
        <a data-bind="attr: {href: website()}">Website</a>
    </div>
    <h1>Foursquare Recommended</h1>
    <div class="card" id="recViewModel" data-bind="foreach: recommendedSpotList  ">
        <div class="expand">
            <h2 class="venueName" data-bind="text:name"></h2>
        </div>
        <div class="cardSupport" data-bind="text:location">
        </div>
        <div class="cardSupport" data-bind="text:category">
        </div>
        <div class="cardSupport" data-bind="text:rating">
        </div>
    </div>
    <script src="js/tester123.js"></script>

like image 861
alphapilgrim Avatar asked Sep 11 '15 22:09

alphapilgrim


1 Answers

I fixed the same problem with some comments on the github page of the project, just make sure to have the same names as the examples and it will work, everything must be in a <div> and the ul must have the class list

Like this

<div id="hacker-list">
   <ul class="list"></ul>
</div>

Link: https://github.com/javve/list.js/issues/9

like image 66
magorich Avatar answered Oct 14 '22 14:10

magorich