jfishbow
jfishbow

Reputation: 253

What is making script run slow on IE8?

I have a search filter where it filter text from a table which is working good on firefox and chrome with no error.

When I try it on IE8 (which is our main browser) it works but the searching is very slow. It like for like a second but i get no errors or anything like it.

Is there anything in my script that could possibly be making it slow on IE8? I took out some of the table collumns since I don't think showing them all makes a difference here.

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script> 
<script language="JavaScript">
 $(document).ready(function () { 
        //add index column with all content. 
        $(".tablecolors tr:has(td)").each(function () { 
            var t = $(this).text().toLowerCase(); //all row text 
            $("<td class='indexColumn'></td>") 
    .hide().text(t).appendTo(this); 
        }); //each tr 
        $("#FilterTextBox").keyup(function () { 
            var s = $(this).val().toLowerCase().split(" "); 

            $(".tablecolors tr:hidden").show(); 
            $.each(s, function () { 
                $(".tablecolors tr:visible .indexColumn:not(:contains('"+ this + "'))").parent().hide(); 
            }); //each 
        }); //key up. 
    }); //document.ready
</script>
....
<table   cellpadding="0" cellspacing="0" class="tablecolors" >
      <thead><th >Department</th></thead>
    <tbody>
    <cfoutput query="GetDeptPhone"  >
    <tr>
        <td >#dept_name# )</td> 
    </tr>
    </cfoutput>
    </tbody>


    </table>

Upvotes: 0

Views: 69

Answers (1)

Andrey
Andrey

Reputation: 658

$.each(s, function () 
{ 
  $(".tablecolors tr:visible .indexColumn:not(:contains('"+ this + "'))").parent().hide(); 
}); 

You modify a DOM model in every iteration, it can be a slow.

Upvotes: 1

Related Questions