Hi group, Wondering if anyone has written any clever rhtml for implementing zebra striped tables. I bet you someone here has a 1-line solution. Rory _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On Oct 13, 2005, at 5:25 PM, Rory Hansen wrote:> Hi group, > > Wondering if anyone has written any clever rhtml for implementing > zebra striped tables. > > I bet you someone here has a 1-line solution. > > Rory > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails ><% @posts.each_with_index do |post, index| -%> <% index % 2 = 0 ? class="even" : class="odd" -%> <tr class="<%= class %>"> <td><%= post.title %></td> <td><%= post.body %></td> </tr> <% end-%> Cheers- -Ezra Zygmuntowicz WebMaster Yakima Herald-Republic Newspaper ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org 509-577-7732
On Oct 13, 2005, at 5:35 PM, Ezra Zygmuntowicz wrote:> > On Oct 13, 2005, at 5:25 PM, Rory Hansen wrote: > > >> Hi group, >> >> Wondering if anyone has written any clever rhtml for implementing >> zebra striped tables. >> >> I bet you someone here has a 1-line solution. >> >> Rory >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> > > <% @posts.each_with_index do |post, index| -%> > <% index % 2 = 0 ? class="even" : class="odd" -%> #<- typo = > should be =<% index % 2 == 0 ? class="even" : class="odd" -%> > <tr class="<%= class %>"> > <td><%= post.title %></td> > <td><%= post.body %></td> > </tr> > <% end-%> > > Cheers- > -Ezra Zygmuntowicz > WebMaster > Yakima Herald-Republic Newspaper > ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org > 509-577-7732 > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >-Ezra Zygmuntowicz WebMaster Yakima Herald-Republic Newspaper ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org 509-577-7732
Hi Rory, On page 29 of the 4 days on rails book http://www.rails4days.pwp.blueyonder.co.uk/Rails4Days.pdf There is the code to implement this feature. Hope this helps Dan On 10/14/05, Rory Hansen <roryhansen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi group, > Wondering if anyone has written any clever rhtml for implementing zebra > striped tables. > I bet you someone here has a 1-line solution. > Rory > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
I would strongly advise against striping with backend code. It has no reason to be mucking around in styles like so. The best solution is to use a pure CSS method, unfortunately IE6 won''t support this. No worries, a little bit of javascript ingenuity will fix this. Here''s a little script I whipped up a while ago: // Zebra Tables, by class var stripe = function() { var tables = document.getElementsByTagName("table"); for(var x=0;x!=tables.length;x++){ var table = tables[x]; if (!table || !HasClass(table, ''alternate'') ) { return; } var trs = tables[x].getElementsByTagName("tr"); even = false; for (var i = 0; i < trs.length; i++) { if (even) AddClass(trs[i], ''even'') even = !even; } } } Basically, if your table has a class of ''alternate'' it will add a class of ''even'' to all even tr''s in that table. Note: this assumes you have a HasClass function. Here''s one for example: // Class Detection //*** This code is copyright 2002-2003 by Gavin Kistner and Refinery; www.refinery.com <http://www.refinery.com> //*** It is covered under the license viewable at http://phrogz.net/JS/_ReuseLicense.txt //*** Reuse or modification is free provided you abide by the terms of that license. //*** (Including the first two lines above in your source code satisfies the conditions.) //***Adds a new class to an object, preserving existing classes function AddClass(obj,cName){ KillClass(obj,cName); return obj && (obj.className+=(obj.className.length>0?'' '':'''')+cName); } //***Removes a particular class from an object, preserving other existing classes function KillClass(obj,cName){ return obj && (obj.className=obj.className.replace(new RegExp("^"+cName+"\\b\\s*|\\s*\\b"+cName+"\\b",''g''),'''')); } //***Returns true if the object has the class assigned, false otherwise. function HasClass(obj,cName){ return (!obj || !obj.className)?false:(new RegExp("\\b"+cName+"\\b")).test(obj.className) } window.onload = stripe; On 10/13/05, Liquid <has.sox-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi Rory, > > On page 29 of the 4 days on rails book > > http://www.rails4days.pwp.blueyonder.co.uk/Rails4Days.pdf > > There is the code to implement this feature. > > Hope this helps > Dan > > On 10/14/05, Rory Hansen <roryhansen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi group, > > Wondering if anyone has written any clever rhtml for implementing zebra > > striped tables. > > I bet you someone here has a 1-line solution. > > Rory > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- Kyle Neath kneath-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://www.neathdesign.com _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
... <tr class="<%= index.even? ? "row_even" : "row_odd" -%>">...</tr> ... fyi, even? is provided by ActiveSupport On 10/13/05, Ezra Zygmuntowicz <ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org> wrote:> > On Oct 13, 2005, at 5:25 PM, Rory Hansen wrote: > > > Hi group, > > > > Wondering if anyone has written any clever rhtml for implementing > > zebra striped tables. > > > > I bet you someone here has a 1-line solution. > > > > Rory > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > <% @posts.each_with_index do |post, index| -%> > <% index % 2 = 0 ? class="even" : class="odd" -%> > <tr class="<%= class %>"> > <td><%= post.title %></td> > <td><%= post.body %></td> > </tr> > <% end-%> > > Cheers- > -Ezra Zygmuntowicz > WebMaster > Yakima Herald-Republic Newspaper > ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org > 509-577-7732 > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
and then of course i found the example in the book <% odd_or_even = 0 for post in @posts odd_or_even = 1 - odd_or_even %> <tr class="line<%= odd_or_even %>">...</tr> <% end %> you''ll need 2 styles, tr.line0 and tr.line1 On 10/13/05, Chris Hall <christopher.k.hall-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> ... > <tr class="<%= index.even? ? "row_even" : "row_odd" -%>">...</tr> > ... > > fyi, even? is provided by ActiveSupport > > On 10/13/05, Ezra Zygmuntowicz <ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org> wrote: > > > > On Oct 13, 2005, at 5:25 PM, Rory Hansen wrote: > > > > > Hi group, > > > > > > Wondering if anyone has written any clever rhtml for implementing > > > zebra striped tables. > > > > > > I bet you someone here has a 1-line solution. > > > > > > Rory > > > _______________________________________________ > > > Rails mailing list > > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > <% @posts.each_with_index do |post, index| -%> > > <% index % 2 = 0 ? class="even" : class="odd" -%> > > <tr class="<%= class %>"> > > <td><%= post.title %></td> > > <td><%= post.body %></td> > > </tr> > > <% end-%> > > > > Cheers- > > -Ezra Zygmuntowicz > > WebMaster > > Yakima Herald-Republic Newspaper > > ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org > > 509-577-7732 > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
On Friday 14 Oct 2005 02:02, Kyle Neath wrote:> I would strongly advise against striping with backend code. It has no > reason to be mucking around in styles like so.Agreed - don''t do the zebra striping in the backend.> The best solution is to use a pure CSS method, unfortunately IE6 won''t > support this. No worries, a little bit of javascript ingenuity will fix > this. Here''s a little script I whipped up a while ago:There''s a great AListApart article on this, which contains some similar stuff to your JavaScript - that''s what I use: http://www.alistapart.com/articles/zebratables In fact, it''s the first Google hit for "zebra tables"... ;-) ~Dave -- Dave Silvester Rent-A-Monkey Website Development Web: http://www.rentamonkey.com/
Thanks for the examples guys. I had implemented it similar to Ezra (as I often do in other languages) but I thought there might be a better way with more joy and less code. :) I''ll dig through some of the responses and see what''s been suggested. I also did see the A List Apart article on Zebra Striping (which is where I stole the name for this post) but, unlike some of the views expressed here, I am not interested in using javascript to implement it. Rory -----Original Message----- From: rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Chris Hall Sent: Thursday, October 13, 2005 7:08 PM To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails] zebra striped tables? and then of course i found the example in the book <% odd_or_even = 0 for post in @posts odd_or_even = 1 - odd_or_even %> <tr class="line<%= odd_or_even %>">...</tr> <% end %> you''ll need 2 styles, tr.line0 and tr.line1 On 10/13/05, Chris Hall <christopher.k.hall-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> ... > <tr class="<%= index.even? ? "row_even" : "row_odd" -%>">...</tr> > ... > > fyi, even? is provided by ActiveSupport > > On 10/13/05, Ezra Zygmuntowicz <ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org> wrote: > > > > On Oct 13, 2005, at 5:25 PM, Rory Hansen wrote: > > > > > Hi group, > > > > > > Wondering if anyone has written any clever rhtml for implementing > > > zebra striped tables. > > > > > > I bet you someone here has a 1-line solution. > > > > > > Rory > > > _______________________________________________ > > > Rails mailing list > > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > <% @posts.each_with_index do |post, index| -%> > > <% index % 2 = 0 ? class="even" : class="odd" -%> > > <tr class="<%= class %>"> > > <td><%= post.title %></td> > > <td><%= post.body %></td> > > </tr> > > <% end-%> > > > > Cheers- > > -Ezra Zygmuntowicz > > WebMaster > > Yakima Herald-Republic Newspaper > > ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org > > 509-577-7732 > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Is there any particular reason for it? I can tell you from a real-life usage perspective, putting backend in control of the table striping causes problems. Perhaps not today, perhaps not in a couple of days - but with regular maintainence it turns out to be a bad idea. Javascript is perfectly suited for this task - enhancing the functionality of a web page. Also, if you''re talking about joy and less code, I''m pretty sure this wins out: class="alternate" Dave>> That is where my script originated, although mine deals with classes, while theirs deals with ID''s. You can only have one ID per page, while you can have many classes per page. Mine actually is a lot more flexible. I''m not sure why they went with ID''s anyway. On 10/13/05, Rory Hansen <roryhansen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Thanks for the examples guys. I had implemented it similar to Ezra (as I > often do in other languages) but I thought there might be a better way > with > more joy and less code. :) I''ll dig through some of the responses and see > what''s been suggested. > > I also did see the A List Apart article on Zebra Striping (which is where > I > stole the name for this post) but, unlike some of the views expressed > here, > I am not interested in using javascript to implement it. > > Rory > > -----Original Message----- > From: rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Chris Hall > Sent: Thursday, October 13, 2005 7:08 PM > To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: Re: [Rails] zebra striped tables? > > and then of course i found the example in the book > > <% > odd_or_even = 0 > for post in @posts > odd_or_even = 1 - odd_or_even %> > <tr class="line<%= odd_or_even %>">...</tr> > <% end %> > > you''ll need 2 styles, tr.line0 and tr.line1 > > > On 10/13/05, Chris Hall <christopher.k.hall-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > ... > > <tr class="<%= index.even? ? "row_even" : "row_odd" -%>">...</tr> > > ... > > > > fyi, even? is provided by ActiveSupport > > > > On 10/13/05, Ezra Zygmuntowicz <ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org> wrote: > > > > > > On Oct 13, 2005, at 5:25 PM, Rory Hansen wrote: > > > > > > > Hi group, > > > > > > > > Wondering if anyone has written any clever rhtml for implementing > > > > zebra striped tables. > > > > > > > > I bet you someone here has a 1-line solution. > > > > > > > > Rory > > > > _______________________________________________ > > > > Rails mailing list > > > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > <% @posts.each_with_index do |post, index| -%> > > > <% index % 2 = 0 ? class="even" : class="odd" -%> > > > <tr class="<%= class %>"> > > > <td><%= post.title %></td> > > > <td><%= post.body %></td> > > > </tr> > > > <% end-%> > > > > > > Cheers- > > > -Ezra Zygmuntowicz > > > WebMaster > > > Yakima Herald-Republic Newspaper > > > ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org > > > 509-577-7732 > > > _______________________________________________ > > > Rails mailing list > > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Kyle Neath kneath-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://www.neathdesign.com _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On 13/10/05, Rory Hansen <roryhansen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks for the examples guys. I had implemented it similar to Ezra (as I > often do in other languages) but I thought there might be a better way with > more joy and less code. :) I''ll dig through some of the responses and see > what''s been suggested. > > I also did see the A List Apart article on Zebra Striping (which is where I > stole the name for this post) but, unlike some of the views expressed here, > I am not interested in using javascript to implement it. >Well, if you do use ''backend'' code to implement it, then do NOT do what''s already been suggested in this thread and use TWO classes. This is css bloat and anyone suggesting it should be ashamed of themselves ;-) Everyone repeat after me "there is no need to add excess attributes to the markup for the default state"! The css for a zebra-striped table looks like this: tr { /* Styles for evens */ } tr.alternate { /* Styles for odds */ } And if it worries you to style every row in the site the same, then style them contextually: table#foo tr { /* Styles for evens */ } table#foo tr.alternate { /* Styles for odds */ } I''m a rank Ruby/Rails newbie, but I think I''ve made the appropriate modification to the other Christopher''s post - though I don''t know if I''ve escaped the quotes correctly: <tr<%= index.even? ? "" : " class=\"alternate\"" -%>>...</tr> -Christopher
On Oct 13, 2005, at 8:53 PM, Christopher wrote:> Well, if you do use ''backend'' code to implement it, then do NOT do > what''s already been suggested in this thread and use TWO classes. This > is css bloat and anyone suggesting it should be ashamed of themselves > ;-) > > Everyone repeat after me "there is no need to add excess attributes to > the markup for the default state"! The css for a zebra-striped table > looks like this:Thank you thank you thank you. I was just gonna write this. ;) -- _Deirdre http://deirdre.net
You say this, but you don''t say what problems. I don''t think there is anything particularly bad about using a bit of Ruby logic to determine what class to apply to a row. Ideally though, the functionality should be wrapped up as a view helper method for clarity. I can understand it possibly being harder to maintain if the table is static, but if its dynamically generated from a recordset, then I can''t see what can go wrong. Here is an example helper: http://www.bigbold.com/snippets/posts/show/411 Both Ruby and JS methods have their pros/cons. Cheers Luke On 10/14/05, Kyle Neath <kneath-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Is there any particular reason for it? I can tell you from a real-life > usage perspective, putting backend in control of the table striping causes > problems._______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On Oct 15, 2005, at 8:56 AM, Luke Redpath wrote:> Here is an example helper: > http://www.bigbold.com/snippets/posts/show/411But this is really bad code. There should not be both even and odd classes. See Christopher''s example from Oct 13 (posted to this list) for a better way of doing it. What I''m using: <% @products.each_with_index do |product, i| %> <% row_class = i%2 == 0 ? '''' : '' class="even"'' %> <tr<%= row_class %>> ... </tr> <% end %> -- _Deirdre http://deirdre.net
Personally I dont think there is much in it.... either use ruby or javascript to stripe tables. The main advantage of using javascript is that you can still add classes to your your table rows to indicate say that a row is selected or what ever because the javascript uses style instead of class. You cant have two classes but you can have style and class. The disadvantage is that the browser needs to js enabled. Kris.
Deidre, my main point was that whatever way you implement this (Ruby-wise), it should be wrapped up in a view helper. On 10/15/05, Deirdre Saoirse Moen <deirdre-mzk6fgDMp2XR7s880joybQ@public.gmane.org> wrote:> > On Oct 15, 2005, at 8:56 AM, Luke Redpath wrote: > > > Here is an example helper: > > http://www.bigbold.com/snippets/posts/show/411 > > But this is really bad code. There should not be both even and odd > classes. > > See Christopher''s example from Oct 13 (posted to this list) for a > better way of doing it. > > What I''m using: > > <% @products.each_with_index do |product, i| %> > <% row_class = i%2 == 0 ? '''' : '' class="even"'' %> > <tr<%= row_class %>> > ... > </tr> > <% end %> > > -- > _Deirdre http://deirdre.net > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Kris Leech wrote:> Personally I dont think there is much in it.... either use ruby or > javascript to stripe tables. > > The main advantage of using javascript is that you can still add classes > to your your table rows to indicate say that a row is selected or what > ever because the javascript uses style instead of class. You cant have > two classes but you can have style and class. The disadvantage is that > the browser needs to js enabled.Um... It''s a bit of a divergence from the original topic, but you *can* have two classes. <div class=''odd selected''>blah</div> is perfectly valid markup, and gives the div both the ''odd'' class and the ''selected'' class. See http://www.w3.org/TR/html4/struct/global.html#h-7.5.2, and I quote: "class = cdata-list [CS] This attribute assigns a class name or set of class names to an element. Any number of elements may be assigned the same class name or names. Multiple class names must be separated by white space characters." -- Alex
On 15/10/05, Luke Redpath <contact-5bSlq4ThgqCxcuGT1ypO+1pr/1R2p/CL@public.gmane.org> wrote:> Deidre, my main point was that whatever way you implement this (Ruby-wise), > it should be wrapped up in a view helper.Can you elaborate please on how you''d do this with a helper. As a rails noob I''m not sure exactly what you mean. Thanks -Luke
The problem, I believe, is when you start mixing in javascript sorting at the client. Then your table looks pants when you move from (for example) order_by_id to order_by_date with some funky DOM management. Striping with javascript ensures its always appropriately striped. Luke Redpath wrote:>You say this, but you don''t say what problems. I don''t think there is >anything particularly bad about using a bit of Ruby logic to determine what >class to apply to a row. Ideally though, the functionality should be wrapped >up as a view helper method for clarity. > >I can understand it possibly being harder to maintain if the table is >static, but if its dynamically generated from a recordset, then I can''t see >what can go wrong. > >Here is an example helper: >http://www.bigbold.com/snippets/posts/show/411 > >Both Ruby and JS methods have their pros/cons. > >Cheers >Luke > >On 10/14/05, Kyle Neath <kneath-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >>Is there any particular reason for it? I can tell you from a real-life >>usage perspective, putting backend in control of the table striping causes >>problems. >> >> > > > >------------------------------------------------------------------------ > >_______________________________________________ >Rails mailing list >Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >http://lists.rubyonrails.org/mailman/listinfo/rails > > >------------------------------------------------------------------------ > >No virus found in this incoming message. >Checked by AVG Anti-Virus. >Version: 7.0.344 / Virus Database: 267.12.0/134 - Release Date: 14/10/2005 > >
On Oct 15, 2005, at 10:01 AM, Alex Young wrote:> Um... It''s a bit of a divergence from the original topic, but you > *can* have two classes. <div class=''odd selected''>blah</div> is > perfectly valid markup, and gives the div both the ''odd'' class and > the ''selected'' class.Right, but you can''t change which row is selected interactively except with JS. which was how I interpreted Kris''s point. -- _Deirdre http://deirdre.net
Deirdre Saoirse Moen wrote:> On Oct 15, 2005, at 10:01 AM, Alex Young wrote: > >> Um... It''s a bit of a divergence from the original topic, but you >> *can* have two classes. <div class=''odd selected''>blah</div> is >> perfectly valid markup, and gives the div both the ''odd'' class and >> the ''selected'' class. > > > Right, but you can''t change which row is selected interactively except > with JS. which was how I interpreted Kris''s point. >Oh, I''m not disputing that. I''m just pointing out that you don''t need to wrangle style with JS, you can just assign an extra class. As I said, a bit of a diversion :-) -- Alex