mirror of
https://github.com/Mottie/tablesorter.git
synced 2025-01-12 15:24:21 +00:00
Added fixedUrl option for use with the widget storage function. Fixes #389.
This commit is contained in:
parent
a33619a4fd
commit
340fdf0138
@ -707,6 +707,23 @@
|
|||||||
<td><a href="example-option-sort-empty.html">Example</a></td>
|
<td><a href="example-option-sort-empty.html">Example</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr id="fixedurl">
|
||||||
|
<td><a href="#" class="toggle2">fixedUrl</a></td>
|
||||||
|
<td>String</td>
|
||||||
|
<td>Undefined</td>
|
||||||
|
<td>
|
||||||
|
This option was added to set a specific page when storing data using the <code>$.tablesorter.storage</code> code. <span class="version">v2.12</span>.
|
||||||
|
<div class="collapsible"><br>
|
||||||
|
More specifically, when the storage function is used, it attempts to give every table a unique identifier using both the page <strong>url</strong> and table <strong>ID</strong> (or index on the page if no id exists). This option allows you to override the current page url (<em>it doesn't need to be a url, just some constant value</em>) and save data for multiple tables across a domain.<br>
|
||||||
|
<br>
|
||||||
|
The table url & id can also be overridden by setting table data attributes <code>data-table-page</code> (url) and <code>data-table-group</code> (id)<br>(e.g. <code><table class="tablesorter" data-table-page="mydomain" data-table-group="financial">...</table></code>)<br>
|
||||||
|
<br>
|
||||||
|
For a bit more detail, specifically on how to use the new storage function options for a custom widget, please refer to <a href="https://github.com/Mottie/tablesorter/issues/389#issuecomment-26594259">issue #389</a>.
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr id="headerlist">
|
<tr id="headerlist">
|
||||||
<td><span class="permalink">headerList</span></td>
|
<td><span class="permalink">headerList</span></td>
|
||||||
<td>Array</td>
|
<td>Array</td>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*! tableSorter 2.8+ widgets - updated 6/4/2013
|
/*! tableSorter 2.8+ widgets - updated 10/18/2013
|
||||||
*
|
*
|
||||||
* Column Styles
|
* Column Styles
|
||||||
* Column Filters
|
* Column Filters
|
||||||
@ -66,10 +66,11 @@ ts.themes = {
|
|||||||
val = (v && v.hasOwnProperty('mywidget')) ? v.mywidget : '';
|
val = (v && v.hasOwnProperty('mywidget')) ? v.mywidget : '';
|
||||||
alert(val); // "data1" if saved, or "" if not
|
alert(val); // "data1" if saved, or "" if not
|
||||||
*/
|
*/
|
||||||
ts.storage = function(table, key, val){
|
ts.storage = function(table, key, val, options){
|
||||||
var d, k, ls = false, v = {},
|
var d, k, ls = false, v = {},
|
||||||
id = table.id || $('.tablesorter').index( $(table) ),
|
c = table.config,
|
||||||
url = window.location.pathname;
|
id = options && options.id || $(table).attr(options && options.group || 'data-table-group') || table.id || $('.tablesorter').index( $(table) ),
|
||||||
|
url = options && options.url || $(table).attr(options && options.page || 'data-table-page') || c && c.fixedUrl || window.location.pathname;
|
||||||
// https://gist.github.com/paulirish/5558557
|
// https://gist.github.com/paulirish/5558557
|
||||||
if ("localStorage" in window) {
|
if ("localStorage" in window) {
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user