Mottie/tablesorter

how can have "x" icon to clear content in Filter textbox under 2.21.4

Closed this issue · 14 comments

I have implemented 2.21.4 to my system, can advise how to add "x" icon in the filter textbox ? thanks.

also, any method can autofocus on a specific filter textbox ?

Regards,
Thomas

Hi @airthomas!

Please see #356, for more information on the "x".

As for autofocusing a filter... you'll need to add some initialization code to do that (demo)

$(function () {
    $('table').tablesorter({
        theme: 'blue',
        widgets: ['zebra', 'filter'],
        initialized: function (table) {
            $(table).find('.tablesorter-filter').eq(2).focus();
        }
    });
});

Hi Mottie,

reset filter icon works great, and initialized function worked on non ajax pager code, once added to ajax-pager tablesorter then not work. Any idea on it ?

Thanks again,
Thomas

Sharing the ajax code would help me find the problem.

Hi Mottie,

Please find this -> http://jsfiddle.net/4mVfu/5655/

is it related to div display ?

Many thanks,
Thomas

is ti due to during the page loaded, the cursor already stay on the filter field, then I click the button, the cursor changed ? can I trigger the focus again in $('#selectUser').click(function () {.....}
Thanks.

i got the solution, many thanks your help.

sorry, one more question.... just find press "Esc" will clear the filter field, can I disable it ?
Thanks.

Using "Esc" to clear the filter doesn't currently have an option to disable it, but it is the default behavior in some browsers. For example, try this demo in Chrome or Opera and the input value gets cleared on escape. It doesn't in Firefox or IE.

So even if I did add an option to toggle that behavior, it won't be the same in all browsers.

I tried to change to type from "search" to "input", like https://jsfiddle.net/x9mzm34L/2/

I think this can be a trade-off to let user choose the "cross icon to clear" or "Esc to clear"

Ok, in the master branch, the filter widget now has a new option filter_resetOnEsc which when true, it normalizes pressing escape to clear the search input across browsers. When set to false, escape is ignored in all browsers.

Many thanks, is it also work on 2.21.4 ?

sorry, would you please advise how can I go to "master branch" ? thanks.

i found the master branch and will try to upgrade my tablesorter to latest version, many thanks.

v2.25.2 has just been released.