MiJaMu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Dec-05 14:56 UTC
stuck on a css selector
Hi, I have been struggling with a particular css selector and i thought maybe someone here has the answer. I''m trying to hide tables whose rows are already hidden. I''ve tried several approaches, but i think it comes down to the css selector. Here''s the code. var hidingtables = $$(''table tr[''style.display = "none"'']) for (i=0;i<tables.length;i++) { tables[i].style.display = "none"; } am i on the right track? ~ Mike --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
As far as the hidingtables variable: var hidingtables = $$(''table tr[style*="display: none"]''); The * will allow it to still catch the needed rows even if they have other values in their style. As far as the loop, I don''t see where you have defined tables in your example. On Dec 5, 9:56 am, "MiJ...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <MiJ...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > I have been struggling with a particular css selector and i thought > maybe someone here has the answer. I''m trying to hide tables whose > rows are already hidden. I''ve tried several approaches, but i think > it comes down to the css selector. Here''s the code. > > var hidingtables = $$(''table tr[''style.display = "none"'']) > for (i=0;i<tables.length;i++) > { > tables[i].style.display = "none"; > > } > > am i on the right track? > ~ Mike--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
MiJaMu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Dec-05 15:22 UTC
Re: stuck on a css selector
oops var hidingtables = $$(''table tr[style*="display: none"]''); for (i=0;i<hidingtables.length;i++) { hidingtables[i].style.display = "none"; } But that $$ returns all rows. i''m trying to loop through each table and check if every row in that table is "display: none". If every row is hidden, then hide that table, otherwise leave the table alone. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Odd, it worked for me in firefox with this as the table: <table> <tr style="display: none; background: red;"> <td>One</td> <td>Two</td> </tr> <tr> <td>One</td> <td>Two</td> </tr> <tr style="display: none;"> <td>One</td> <td>Two</td> </tr> </table> If you don''t have an excessive amount of rows to traverse, you could do the following: $$(''table tr'').each(function(row){ if(row.visible()) { row.hide(); }}); On Dec 5, 10:22 am, "MiJ...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <MiJ...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> oops > > var hidingtables = $$(''table tr[style*="display: none"]''); > for (i=0;i<hidingtables.length;i++) > { > hidingtables[i].style.display = "none"; > > } > > But that $$ returns all rows. > i''m trying to loop through each table and check if every row in that > table is "display: none". If every row is hidden, then hide that > table, otherwise leave the table alone.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
MiJaMu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Dec-05 15:41 UTC
Re: stuck on a css selector
in other words, that selector selects all rows with a "display: none" attribute. but i need all tables whose rows are all "display: none" i could probably do this with a nested loop, but there''s got to be a better way :) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
MiJaMu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Dec-05 15:47 UTC
Re: stuck on a css selector
that''s close, but It still doesn''t check whole tables. it iterates through each row. btw, i have ~ 700 rows spread across 26 tables --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Aren''t these two the same? that selector selects all rows with a "display: none" attribute. but i need all tables whose rows are all "display: none" Can you post an example of a row? On Dec 5, 10:47 am, "MiJ...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <MiJ...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> that''s close, but It still doesn''t check whole tables. it iterates > through each row. btw, i have ~ 700 rows spread across 26 tables--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
MiJaMu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Dec-05 16:03 UTC
Re: stuck on a css selector
let me show you my example. http://www.jottodesk.com/samples/pl_example.pdf i''ve filtered the page to show only rows that match "ford" in the make. Now I need to hide the tables that had no matches (i.e. tables with all rows hidden) thanks for helping me! This message board is responsive. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
MiJaMu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Dec-05 16:07 UTC
Re: stuck on a css selector
here''s a better picture of the page: http://www.jottodesk.com/samples/pl_example.png --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
$$(''table'').reject(function(table) { return table.select(''tr'').any(Element.visible) }) The code is self explanatory - get all tables, then reject those that have at least one visible row. In other words collect all tables that have all rows hidden. You could then do call .invoke(''hide'') on this collection to hide them all. If we''re talking about many tables, I suggest using .each(Element.hide) as it''s usually ~3x faster than invoke Best, kangax --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
MiJaMu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Dec-05 19:29 UTC
Re: stuck on a css selector
would a tr in the thead trip this up? how can i tell it to ignore the thead? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
MiJaMu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Dec-05 19:32 UTC
Re: stuck on a css selector
figured it out. add ''tbody'' to the select! var htables = $$(''table'').reject(function(table){ return table.select(''tbody tr'').any(Element.visible) }); On Dec 5, 1:29 pm, "MiJ...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <MiJ...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> would a tr in the thead trip this up? how can i tell it to ignore the > thead?--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---