tags:

views:

19

answers:

1

Hi

I have written a search filter. It shows/hides some thumbnails in a video gallery based on text typed into an input field. Te input field has a keyUp event.

$('.videoSearch').keyup(function(e){
  var searchString = $(e.srcElement).val();
  var el = $($(e.srcElement).parents().find('.videoThumbs').first());
  $(el).find(".title:not(:contains('"+searchString+"'))").each(function(i,e){
   $(e).parent().parent().parent().parent().parent().parent().fadeOut(300);
  });
  $(el).find(".title:contains('"+searchString+"')").each(function(i,e){
   $(e).parent().parent().parent().parent().parent().parent().fadeIn(300);
  });
 });

It works great in Opera, IE (7,8) and Chrome but in firefox. The keyUp event fires as expected (also in firefox) but no thumbs gets hidden. Firebug logs no errors in the console.

Any help would be appreciated Thanks in advance \JePpE

A: 

As a workaround you can use the filter function and code the criteria manually:

$(".title").filter(function() { return $(this).html().indexOf(searchString) < 0; })
    .each (...);

Should work under any browser.

Xion
Xion! This is indeed a more flexible filtering routine wich i am now using in my script. However i found that the source of the error was elsewhere. Apperently Firefox does not support the (e.srcElement) part of the event object. As soon as i replaced it with this it worked. Actually the script i posted works in firefox as well if you replace e.srcElement with this. I'm not shure exactly what to do here as your answer did not solve my problem, but it was (in my oppinion) a better way to do the filtering, so im gonna accept your answer. Thanks man.
Van den Sohn
To be more accurate you need to replace $(e.srcElement) with $(this). Now everybody should know what i am talking about :)
Van den Sohn
Thanks :) IIRC the e.srcElement should be e.target. But since you're using jQuery, it's likely better to just go with $(this).
Xion