Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Search function on (disabled)input fields

I have a simple search function that I use on a table of information, but since I turned the text in the table into editable fields the search function isn't working anymore.

I tried to troubleshoot it in a few different ways, but can't seem to get it working.

Here's what I have got so far:

var $rows = $('.list #data');
$('#search').keyup(function() {
    var val = $.trim($(this).val()).replace(/ +/g, ' ').toLowerCase();

$rows.show().filter(function() {
    var text = $(this).text().replace(/\s+/g, ' ').toLowerCase();
    return !~text.indexOf(val);
}).hide();
});

This works just fine on simple plain text tables. Here's a JSFiddle that shows you what I am trying to accomplish:

https://jsfiddle.net/je9mc9jp/8/

like image 995
Brayn Avatar asked Oct 17 '22 22:10

Brayn


1 Answers

//SEARCH
var $rows = $('.list input');
$('#search').keyup(function() {
    var val = $.trim($(this).val()).replace(/ +/g, ' ').toLowerCase();

    $rows.show().filter(function() {
        var text = $(this).val().replace(/\s+/g, ' ').toLowerCase();
        return !~text.indexOf(val);
    }).hide();
});
like image 122
Bob Dust Avatar answered Nov 03 '22 20:11

Bob Dust