Estirpicidades
Estirpicidades

Reputation: 163

List.js default sorting table

I'm using list.js library (http://www.listjs.com/), to sort some tables. I want to know if it is possible to get a default sort when page loads without click nothing.

Upvotes: 6

Views: 2509

Answers (1)

jwhazel
jwhazel

Reputation: 984

Lets say you initialize your list like so:

var myList = new List('my-list', {
    valueNames: ['mySortableClass1', 'mySortableClass2', 'mySortableClass3']
});

Simply call this right after that block:

myList.sort("mySortableClass1", {
    order: "desc"
})

Upvotes: 16

Related Questions