José Quiñones Flores 4564da0130 Added Laravel project and removed sensitive data | 4 years ago | |
---|---|---|
.. | ||
js | 4 years ago | |
license.txt | 4 years ago | |
readme.md | 4 years ago |
So what’s it good for? Well, let’s say you want to display a long list of fairly uniform tabluar data, like stock exchange listings or sport statistics but you don’t want your users to get lost in the data as they scroll down on the page.
StickyTableHeaders to the rescue: By applying the StickyTableHeaders jQuery plugin to the table, the column headers will stick to the top of the viewport as you scroll down.
Go ahead and try out a demo.
The code is based on this proof of concept.
The best way to install is using Bower:
bower install StickyTableHeaders
Alternatively, you can download the latest version from jquery.stickytableheaders.min.js.
Initializing the plugin is pretty straight forward:
$('table').stickyTableHeaders();
To remove the plugin:
$('table').stickyTableHeaders('destroy');
$(window).trigger('resize.stickyTableHeaders');
You can initialize the plugin with an options map to tweak the behavior. The following options are supported:
fixedOffset
A number or jQuery object specifying how much the sticky header should be offset from the top of the page:
$('table').stickyTableHeaders({fixedOffset: $('#header')});
scrollableArea
A DOM element or jQuery object. Allows you to overwrite which surrounding element is scrolling. Defaults to window
. Check this demo for an example
As described in pull request #33 responsive pages might need to re-initialize the plugin when the user resizes his browser. This is can be done by calling the plugin with the new options:
$('table').stickyTableHeaders({fixedOffset: [new-offset]});
If any of this is confusing, please check out the /demo folder. There are a couple of examples in there. E.g. you can see how to use it with Twitter Bootstrap.
<th>
s explicitly in the css in order to make the plugin workThe plugin has been verified to work in:
NOTE: It does not work in Internet Explorer 7 (but it degrades nicely)