Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List.js default sorting table

Tags:

sorting

listjs

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.

like image 664
Estirpicidades Avatar asked Dec 09 '22 01:12

Estirpicidades


1 Answers

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"
})
like image 146
jwhazel Avatar answered Feb 04 '23 19:02

jwhazel