javascript - jQuery filter table with multi select -


i'm trying filter table filters. simple selects, , others multiples. simple ones, that's ok, not multiple.

i want follow logic :

  1. passing through array contains filter (filtre_transports)
  2. passing through array contains value(s) (ligne_transports)
  3. if element of 1. isn't in 2. not display line (transports_matches = false)

i made code :

// pass through each line of table jquery('#agents_liste tbody tr').not('.vide').each(function() {     var transports_matches = true;      // ligne_transports array contains values compare filter     var ligne_transports = jquery(this).children('td').eq(2).text().split('###');      // filtre_transports array contains selected val of multi select     jquery(filtre_transports).each(function() {         var filtre = jquery(this);         var filtreok = false;          jquery(ligne_transports).each(function() {             if (filtre == jquery(this)) {                 filtreok = true;                 return false;             }         });          if (!filtreok) {             transports_matches = false;             return false;         }     }); }); 

the problem : when have filters selected, result transports_matches false.

btw, saw this post answer use classes, there way without them ?

edit : can see jsfiddle here.

thanks

fixed: http://jsfiddle.net/r4mfv/2/

you had couple of issues:

  1. $(filtre_transports).each not way iterate on array, should use $.each(filtre_transports, function() {...}).

  2. you should cast filtre , this string before comparing them.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -