JavaScript jQuery Real Time Search - Remove Table Header Too jquery real time update,jquery real time validation,jquery real

I am using the regular expression search code at this link, to allow real time search through a rather large table being populated server-side via php.

With a slight twist to the scenario describe in the above link, I am using table header tags to group (label) chunks of table row's together. I am preventing these table header row's from disappearing with the rest of the table row's so that when searching, the results are still nested in their group.

I would like the table header row's to disappear too, but only when there are no table row's between it and the next table header row. I'm not sure if counting row's will work, since the row's aren't gone, they're just hidden.

As an example, this is how my table is laid out:

HTML:

 <table>
  <tr>
     <th colspan="2">Group 1</th>
  </tr>
  <tr  class="searchable">
    <td>Record 1</td>
    <td>Record 2</td>
  </tr>
  <tr  class="searchable">
    <th>Group 2</th>
  </tr>
  <tr>
    <td>Record 3</td>
    <td>Record 4</td>
  </tr>
</table>

jQuery:

$( document ).ready(function() {
    var $rows = $('tr.searchable');

    $('#search').keyup(function(e) {

        if (e.keyCode == 27) { $(this).val("") }

        var val = '^(?=.*\\b' + $.trim($(this).val()).split(/\s+/).join('\\b)(?=.*\\b') + ').*$',
            reg = RegExp(val, 'i'),
            text;

        $rows.show().filter(function() {
            text = $(this).text().replace(/\s+/g, ' ');
            return !reg.test(text);
        }).hide();
    });
});

All help is appreciated!! Thanks!

Answer:1

I solved my dilemma by adding another class (unique to each group/label) and within the '.keyup()' section counting the ':visible' rows of each class. Once the number of rows in each class dropped below a specified number, I used '.hide()' in an if statement to make the table headers disappear. The else side of the if statement used '.show()' to bring the table headers back if their classes count rose above the specified number.

Answer:2

Is there a way to prevent a new defined function to be called as constructor in JavaScript? Like throw out error when placing new before calling it.

Is there a way to prevent a new defined function to be called as constructor in JavaScript? Like throw out error when placing new before calling it.

  1. create javascript function with parameters
  2. create javascript function in html
  3. create javascript function with callback
  4. create javascript function in angular
  5. create javascript function from string
  6. create javascript function with string parameter
  7. create javascript function in js file
  8. create javascript function dynamically
  9. create javascript function with array parameter
  10. create javascript function
  11. create javascript function in code behind c#
  12. create javascript function in php
  13. create javascript function with return value
  14. create javascript function in typescript
  15. create javascript function library
  16. create javascript function in asp.net
  17. create javascript function in c#
  18. create javascript function object
  19. create javascript function on the fly
  20. create javascript function in java

Chart.js 2+ does not return percentages for legend items in pie charts anymore. I am storing the legend in the separate item in my html named #legend. Then I set it's innerHTML to myPieChart....

Chart.js 2+ does not return percentages for legend items in pie charts anymore. I am storing the legend in the separate item in my html named #legend. Then I set it's innerHTML to myPieChart....

I want to save and an image that is user generated, and I can't use anything other than HTML an JavaScript. Is there a way to do it? Any help is appreciated.

I want to save and an image that is user generated, and I can't use anything other than HTML an JavaScript. Is there a way to do it? Any help is appreciated.

Listening to scroll events in Safari iOS browser triggers the console message every time, even on the momentum, but in the cordova built app that triggers only when the scroll has stopped. el-with-...

Listening to scroll events in Safari iOS browser triggers the console message every time, even on the momentum, but in the cordova built app that triggers only when the scroll has stopped. el-with-...

  1. cordova momentum scrolling