You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Works with **JavaScript generated tables**. (since we are using an eventListener)
46
48
@@ -60,12 +62,6 @@ You can find a simple demo on <https://tofsjonas.github.io/sortable/>
60
62
61
63
There are three ways to use sortable, all of which have their pros and cons. [S Anand](https://github.com/sanand0) and [dkhgh](https://github.com/dkhgh) had some [interesting thoughts](https://github.com/tofsjonas/sortable/issues/28) about it.
62
64
63
-
1. Include a link to [jsDelivr](https://www.jsdelivr.com/package/gh/tofsjonas/sortable). (easiest)
64
-
65
-
2. Copy the file from [jsDelivr](https://www.jsdelivr.com/package/gh/tofsjonas/sortable) or [Github](https://github.com/tofsjonas/sortable) and put it in your assets folder. (in between)
66
-
67
-
3. Install the [npm package](https://www.npmjs.com/package/sortable-tablesort). (most reliable)
68
-
69
65
### 1. link to jsDelivr
70
66
71
67
```html
@@ -87,8 +83,8 @@ There are three ways to use sortable, all of which have their pros and cons. [S
I'm not sure if it's a good idea to have it in the main css, BUT if you are using the above `sortable(.min).css` file (not the -base files) and want sticky headers, you can simply add the class `sticky` to the table.
224
+
225
+
Blame [razorkyle](https://github.com/razorkyle), it was his idea! 😜
226
+
227
+
```html
228
+
<tableclass="sortable sticky">
229
+
...
230
+
</table>
231
+
```
232
+
233
+
If you are not using the css file, you can use the following css:
234
+
235
+
```css
236
+
.sortabletheadth {
237
+
position: sticky;
238
+
top: 0;
239
+
z-index: 1;
240
+
}
241
+
```
242
+
225
243
## Sorting sizes, dates and such
226
244
227
245
Using the `data-sort` attribute in `tbody` > `td` you can have one visible value and one sortable value. This is useful in case you have for instance sizes like kb, Mb, GB, or really weird date formats. 😉
@@ -410,9 +428,9 @@ Sortable is not very accessible in its raw form. It does not support screen read
By including the file the global function `enhanceSortableAccessibility` will automatically run through all existing `.sortable` tables, but you can also run it manually, like so:
The function adds an `aria-label` to each th, as well as `tabindex="0"` to each th in the thead of each table, making it possible to tab through the headers. It updates the `aria-label` depending on the direction.
425
443
426
-
if you want to import it instead this _should_ work: (I haven't tested it)
0 commit comments