jennschiffer / timbles.js

a very simple jQuery plugin for tables, made by the person who literally did not invent tables
MIT License
38 stars 4 forks source link

Support multiple tables for all timbles methods #23

Closed edelooff closed 8 years ago

edelooff commented 8 years ago

When a page has multiple tables, it's easy enough to make all of them sortable with a simple timbles init call:

$( 'table' ).timbles( { sorting: true } )

However, later sorting all of these tables by their first column, paginating them (after init), or changing their page number either doesn't work (for sorting), or causes very weird behavior (in case of paginating and such).

$( 'table' ).timbles( 'sortColumn', 0 );  // sorts first table in query
$( 'table' ).timbles( 'enablePagination', 10 );  // fails or does bizarre things
$( 'table' ).timbles( 'goToPage', 2 );  // similarly bizarre

Currently the init method has a wrapper that performs init for .each() of the elements in the jQuery selector. I propose to move that wrapper to the .timbles() function that is added to the jQuery object. This simplifies the plugin methods themselves, and provides good handholds for external callers.

edelooff commented 8 years ago

This has been added in #33.