Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
a very simple jQuery plugin for tables, made by the person who literally did not invent tables
timbles is a very lightweight jQuery plugin (lol is that an oxymoron) that allows you to add sorting to an existing <table>
. That's it. Actually, it can also create the table for you with some JSON data and minimal configuration. It's p easy. I think it would make for a great base for table functionality you'd want to build into your apps.
You need to enqueue jQuery (duh) and the timbles.js file.
<script src="jquery.js"></script>
<script src="timbles.js"></script>
Let's say you have a table on your page already, all populated with data:
Name | Size | Kind | Date Added | Notes |
---|---|---|---|---|
dhtmlconf.png | 77 KB | PNG Image | August 31, 2014, 11:16 PM | dhtmlconf logo |
icla.pdf | 26 KB | Adobe PDF document | August 27, 2014, 12:51 PM | Individual Contributor License Agreement |
Slime Girls - Vacation Wasteland EP.zip | 72.9 MB | ZIP archive | August 25, 2014, 9:40 PM | cool chiptunes from lwlvl |
And here is the source code:
<table border="1">
<thead>
<tr>
<th id="name">Name</th>
<th id="size">Size</th>
<th id="kind">Kind</th>
<th id="date-added">Date Added</th>
<th id="notes" class="no-sort">Notes</th>
</tr>
</thead>
<tr>
<td>dhtmlconf.png</td>
<td>77 KB</td>
<td>PNG Image</td>
<td>August 31, 2014, 11:16 PM</td>
<td>dhtmlconf logo</td>
</tr>
<tr>
<td>icla.pdf</td>
<td>26 KB</td>
<td>Adobe PDF document</td>
<td>August 27, 2014, 12:51 PM</td>
<td>Individual Contributor License Agreement</td>
</tr>
<tr>
<td>Slime Girls - Vacation Wasteland EP.zip</td>
<td>72.9 MB</td>
<td>ZIP archive</td>
<td>August 25, 2014, 9:40 PM</td>
<td>cool chiptunes from lwlvl</td>
</tr>
</table>
You don't need to generate a new table with JSON because your table is there already. And you just want to be able to make it sortable. Then just call this after you enqueued timbles.js as per the above install directions:
// get your table
var $table = $('table');
// call timbles
$table.timbles({ sorting: true });
In order for sorting to work, the <th>
cells need to have an id
attribute and the parent <tr>
of the header rows needs to be within a <thead>
tag. Again, view the source above for the example.
If you want to initially sort your table on load, there are sorting
properties you can set:
// get your table
var $table = $('table');
// call timbles with sorting property
$table.timbles(
sorting: {
order: 'asc', // 'asc' for ascending sort, 'desc' for descending
keyId: 'name', // the id of the column you want to initially sort by
}
});
If you don't want all of the columns to be sortable, add the class no-sort
to the <th> element of the column you do not want to be sortable.
If your data is in a JSON file, add a <table>
element to your page and then call timbles
on it.
<table id="example"></table>
// get your table
var $table = $('#example');
// call timbles with dataConfig property
$table.timbles({
dataConfig: {
json: 'data.json', // the json file
sorting: true, // if you want columns to be sortable
columns: [
/**
* you have to set the column headers with the following required properties:
* - label (string), the text between <th> and </th>
* - id (string), the json object property attributed to the column
*
* and here are some optional properties:
* - noSorting (boolean), if set to true the column won't be sortable
* if you have the non-column property sorting set to true
*
*/
{ label: 'Name', id: 'name' },
{ label: 'Size', id: 'size' },
{ label: 'Kind', id: 'kind' },
{ label: 'Date Added', id: 'dateAdded' },
{ label: 'Notes', id: 'notes', noSorting: true }
]
},
});
When you sort ascending, the sort-asc
class is added to the <th>
header. If you sort descending, the sort-desc
class is added to the <th>
header. So you can, like, use CSS to add arrows whenever those classes are set and that's p cool I think.
This was made within a few days for jqCon Chicago on 9/12/2014 and therefore is incomplete and not well documented. This is what I get for having to launch something whenever I give a talk. I'll refine this and add more features while retaining the philosophy of staying simple.
MOST IMPORTANTLY: HAVE FUN.
FAQs
a p chill jQuery table plugin, made by people who literally did not invent tables
We found that timbles demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.