The perfect library for adding search, sort, filters and flexibility to tables, lists and various HTML elements. Built to be invisible and work on existing HTML.

Overview

List.js

Perfect library for adding search, sort, filters and flexibility to tables, lists and various HTML elements. Built to be invisible and work on existing HTML. Really simple and easy to use!

Donate npm version CircleCI codecov jsDelivr Hits

Core idea

  • Simple and invisible
  • Easy to apply to existing HTML
  • No dependencies
  • Fast
  • Small
  • Handle thousands of items

Features

  • Works both lists, tables and almost anything else. E.g. <div>,<ul>,<table>, etc.
  • Search Read more ›
  • Sort Read more ›
  • Filter Read more ›
  • Simple templating system that adds possibility to add, edit, remove items Read more ›
  • Support for Chrome, Safari, Firefox, IE9+

Download / Install

Via NPM
npm install list.js
Via Bower
bower install list.js
Via CDNJS
<script src="//cdnjs.cloudflare.com/ajax/libs/list.js/2.3.1/list.min.js"></script>
Via Direct Download

Questions / How to?

https://stackoverflow.com/questions/tagged/list.js

Demo / Examples

Documentation

Thanks to all lovely contributors! Want to join them?

Creator

Jonny Strömberg @javve
Image of Jonny I hope you like the lib. I’ve put a lot of hours into it! Feel free to follow me on Twitter for news and donate a coffee for good karma ;)

License (MIT)

Copyright (c) 2011-2020 Jonny Strömberg <[email protected]> javve.com

Comments
  • Feature request: Allow looking at data attribute instead of content

    Feature request: Allow looking at data attribute instead of content

    When I'm sorting various things the default alphanumeric sort is nice, but doesn't cover all my needs. Many times I have to create a custom sort function, and its kind of annoying to only be able to sort on what information you are presenting in that tag.

    As an example, the alphanumeric sort can't handle $120,200.00 (dollar signs and commas). So I have to create a custom function, but in that function I have to manually strip out the $ and , before I have something I can work with sort wise.

    Next version 
    opened by bobspryn 25
  • Cannot read property 'childNodes' of undefined

    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)

    opened by counterposition 19
  • Examples on home page do not work

    Examples on home page do not work

    Hi,

    Examples not working: E.g. click on " /examples/add-get-remove/" link here https://listjs.com/examples/add-get-remove/ does nothing. There are some errors in console: image

    opened by ognjen-petrovic 15
  • Object doesn't support property or method 'getElementsByClassName'?

    Object doesn't support property or method 'getElementsByClassName'?

    First off: love the script - thanks for writing it.

    It's probably something stupid that I'm doing, but I'm getting this error when testing in IE pre version 9:

    SCRIPT438: Object doesn't support property or method 'getElementsByClassName' list.js, line 615 character 21

    I tried adding a couple different 'getElementsByClassName' functions for older browser versions, but none have worked. I doubt this is a bug of List.js - but I am stumped - any help would be appreciated.

    My page is here: www.sureservo.com/gearbox/selector/

    opened by only1chip 13
  • Update dists to work with the latest (2.1.0) version of RequireJS

    Update dists to work with the latest (2.1.0) version of RequireJS

    dist/list.js and dist/list.min.js seem to assume an older version of RequireJS that had different semantics for define. List.js itself is up-to-date and I simply ran grunt dist to generate the correct files. It's a minor change, as can be seen https://github.com/civitaslearning/list.js/compare/master...update-dists. This is especially important for using the library with bower.

    Next version 
    opened by gaurav-sanghani 11
  • IE8 still not work in v1.0.1 :/

    IE8 still not work in v1.0.1 :/

    Thank u so much for looking into this,but it seems still not work :-(

    ----v1.0.1 existing list---- http://codepen.io/NewGuyUseGit/pen/zrmaA http://codepen.io/NewGuyUseGit/full/zrmaA

    ----v1.0.2 fuzzy search---- http://codepen.io/NewGuyUseGit/pen/wzajt http://codepen.io/NewGuyUseGit/full/wzajt

    opened by NewGuyUseGit 11
  • Empty list display an inexistent element.

    Empty list display an inexistent element.

    When the initialization is made using this options and an empty list:

    var options = {
      valueNames: ["text", "page"],
      item: "<div style='background:red;width:100px;height:30px;'></div>"
    };
    var userList = new List('users', options,[]);
    

    The list shows an empty element node ss could be seen at this Pen: http://codepen.io/anon/pen/BNxJxZ

    Next version 
    opened by Moykn 10
  • Empty values sorted incorrectly

    Empty values sorted incorrectly

    There's a regression bug, the issue was fixed in alphanumeric sort https://github.com/javve/list.js/pull/136 but is present in natural sort algorithm used now. As a result, empty strings are always on top, whatever the sort direction.

    The correct way would be not to do any string replacement at all if one of (or both) passed values are null/empty

    opened by enlait 10
  • Search sometime not working on IE7

    Search sometime not working on IE7

    I have a site using list.js where search is not working with IE7. Everything else is working (filtering, sorting). Examples on http://listjs.com/examples/standard.html are working.

    I don't know how to debug under IE.

    list.min.js updated to last version.

    List created using:

    var options = { item: 'pnt-item', listClass: 'pnt-list', searchClass: 'pnt-search', sortClass: 'pnt-sort', page: '1000' };
    list = new List( 'pnt-main', options, jsondata.data );
    

    pnt-item is a template (style="display:none;" on father) on tr containing th and td.

    list.search('foo');
    

    produce a correct list under Firefox but an empty list under IE7

    Need more information 
    opened by koocotte 10
  • No sorting when adding <li> elements dynamically

    No sorting when adding
  • elements dynamically
  • First of all..nice job it works fine, but...

    I've created a piece code where I create the

  • dynamically

    html:

    • Sort by name
    • Sort by category

      ...

      javascript: var selector = ".list"; var html = '

    • aaa<'/li>'; $(html).insertAfter(selector); // The same repeated for bbb, ccc and ddd featureList.add({name:'aaa'}); // The same repeated for bbb, ccc and dd

      Afterwards the sorting does not work. I get the following error "Uncaught TypeError: Cannot call method 'cloneNode' of null" line 563 of list.js.

      Is there a solution for this problem or is there another way to add

    • items and still able to sort

      Thanks in advance

      Marco

    • opened by mortelee 10
    • Paging with large amount of classes

      Paging with large amount of classes

      Hello, first of all i want to thank you for your script.

      I have some sort of problem with it, and i hope you can help me.

      I created list with more than 10 classes and 1000+ objects with paging, so i can easily navigate through objects. But sadly, paging stop working after second class of objects with amount more than objects on page.

      Example: 100 objects within 4 'class'. 25 objects each. 10 objects on page. After filtering for 'class' we have 3 pages with first 25 elements and working paging. But after filtering for second class we have 3 pages with 25 next objects but navigating on pages 2-3 doesn't work. Same thing happening for all other classes.

      100 objects in a row, first 25 objects - first class, second 25 objects - second class etc.

      I am terrible sorry for my language, and i hope that you will help me

      Will fix 
      opened by Fund64 9
    • Differences between search and filter

      Differences between search and filter

      Are searching and filtering more or less the same and just two different approaches to reduce a list? I cannot find enough information about these methods. What are the differences or intentions? When to use what? Are there any side effects?

      Is it true, that if I want to search for different item values, I have to use filter? It seems search allows only to search for a single value.

      Thanks for you input!

      opened by robsch 0
    • Pagination

      Pagination

      Hi,

      I have a problem with "select" on the first page, the button works fine but on the following pages it doesn't work.

      Does anyone have an idea how to solve this?

      • First page
      Screenshot 2022-07-05 at 17 18 15
      • Second page
      Screenshot 2022-07-05 at 17 20 58

      No styling for the Select2 button.

      opened by KajetanDudczak 0
    • valueNames not work as expected

      valueNames not work as expected

      var options = {
          valueNames: ['id', { data: ["id"] }, 'name'],
          item: "<li class='list-group-item'><span class='id'></span><span class='name'></span></li>"
       };
      

      For value item {id: 1, name: 'Hello World}, I expect it will render <li class='list-group-item' data-id='1'><span class='id'>1</span><span class='name'>Hello World</span></li>, but it renders <li class='list-group-item' data-id><span class='id'>1</span><span class='name'> where data-id is empty.

      opened by AlanNggg 0