Any ideas on how to speed this up in IE (the filtering process performs decent in Firefox, but almost unusable in IE). Basically, it’s a tag cloud with a filter text box to filter the cloud.
<html>
<head>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#tagFilter').keyup(function(e) {
if (e.keyCode==8)
{
$('#cloudDiv > span').show();
}
$('#cloudDiv > span').not('span:contains(' + $(this).val() + ')').hide();
});
});
</script>
</head>
<body>
<input type="text" id="tagFilter" />
<div id="cloudDiv" style="height: 200px; width: 400px; overflow: auto;">
<script type="text/javascript">
for (i=0;i<=1300;i++)
{
document.write('<span><a href="#">Test ' + i + '</a> </span>');
}
</script>
</div>
</body>
</html>
thanks,
rodchar
Since the tags should be unique (it shouldn’t make sense to have the tag “awesome” in the cloud twice), give each span an “id” value based on a cleaned-up version of the tag string (replace spaces with underscores, etc etc). That should make things a lot faster, because the filter can just go by “id” value.
In fact, you don’t even need a filter: just hide all the
<span>elements in the cloud, and then show the one with the “id” value formed from the current field value. If there isn’t one, then there isn’t one, but if there is, that’ll be very fast.