<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:series="http://unfoldingneurons.com/"
> <channel><title>Comments on: MooTools Zebra Table&#160;Plugin</title> <atom:link href="http://davidwalsh.name/mootools-zebra-table-plugin/feed" rel="self" type="application/rss+xml" /><link>http://davidwalsh.name/mootools-zebra-table-plugin</link> <description>Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</description> <lastBuildDate>Wed, 23 May 2012 14:01:31 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>By: Heikki Naski</title><link>http://davidwalsh.name/mootools-zebra-table-plugin#comment-22331</link> <dc:creator>Heikki Naski</dc:creator> <pubDate>Mon, 17 Jan 2011 08:01:23 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2168#comment-22331</guid> <description>&quot;Seeing how you can accomplish this with some CSS, PHP + Modulo operator and loop I’m not sure how much sense it makes to rely upon JS to do this task for you.&quot;Outputting the stripes server-side, you&#039;d need to add that bit of logic to every table you output. It&#039;s not much code, about 5 rows, but it&#039;s duplication nonetheless and requires testing each table separately. Using JS to modify all tables of say, given class or id, you&#039;d have the logic in just one place, with the benefits of centralized control.Of course, if you happen to have a method of generating the tables through a single routine in the server-side code, you&#039;d then only have to code the striping once, but a lot of us don&#039;t probably have that luxury always, especially with legacy apps.Using PHP would obviously work without JS, so it all depends on can you trust the user to have JS on.</description> <content:encoded><![CDATA[<p>&#8220;Seeing how you can accomplish this with some CSS, PHP + Modulo operator and loop I’m not sure how much sense it makes to rely upon JS to do this task for you.&#8221;</p><p>Outputting the stripes server-side, you&#8217;d need to add that bit of logic to every table you output. It&#8217;s not much code, about 5 rows, but it&#8217;s duplication nonetheless and requires testing each table separately. Using JS to modify all tables of say, given class or id, you&#8217;d have the logic in just one place, with the benefits of centralized control.</p><p>Of course, if you happen to have a method of generating the tables through a single routine in the server-side code, you&#8217;d then only have to code the striping once, but a lot of us don&#8217;t probably have that luxury always, especially with legacy apps.</p><p>Using PHP would obviously work without JS, so it all depends on can you trust the user to have JS on.</p> ]]></content:encoded> </item> <item><title>By: Chris</title><link>http://davidwalsh.name/mootools-zebra-table-plugin#comment-11939</link> <dc:creator>Chris</dc:creator> <pubDate>Thu, 17 Sep 2009 13:26:42 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2168#comment-11939</guid> <description>I&#039;ve been modifying this plugin somewhat for a project I am working on, and I&#039;ve encountered some problems with it.The project I am working on involves hierarchical data in a table, arranged as a series of &#039;entry&#039; rows and &#039;folder&#039; rows. Clicking on a folder row hides or shows the corresponding hierarchy of entries or subfolders. This was easy enough, but I wanted to use this class to recolour the table rows dynamically (as hiding a bunch of rows may throw off the zebra effect).Modifying the code so that it checked for tr.style.display != &#039;none&#039; was trivial, as was adding the extra voodoo to make the zebra effect work independently of row number, but then I found the code did not work reliably after more than one call.The problem was actually something I should have noticed from the start: zerbarize() does tr.addClass(klass).addEvents( ... ); *but it doesn&#039;t remove the style classes or events before doing so*, so each call to zebraisze() is just adding classes and event handlers rather than replacing the existing ones!In the end, I used the following code:var options = this.options, klass = pos % 2 ? options.cssEven : options.cssOdd;// We might not know which class we have (if any), so check for either
if(tr.hasClass(options.cssEven)) {
tr.removeClass(options.cssEven);
} else if(tr.hasClass(options.cssOdd)) {
tr.removeClass(options.cssOdd);
}// This is rather harsh, but provided the only events get added in zebraize()
// it should be safe enough...
tr.removeEvents();//start the events!
tr.addClass(klass).addEvents(..... etc....I can link you to a pastebin of the complete modified version if you&#039;re interested.</description> <content:encoded><![CDATA[<p>I&#8217;ve been modifying this plugin somewhat for a project I am working on, and I&#8217;ve encountered some problems with it.</p><p>The project I am working on involves hierarchical data in a table, arranged as a series of &#8216;entry&#8217; rows and &#8216;folder&#8217; rows. Clicking on a folder row hides or shows the corresponding hierarchy of entries or subfolders. This was easy enough, but I wanted to use this class to recolour the table rows dynamically (as hiding a bunch of rows may throw off the zebra effect).</p><p>Modifying the code so that it checked for tr.style.display != &#8216;none&#8217; was trivial, as was adding the extra voodoo to make the zebra effect work independently of row number, but then I found the code did not work reliably after more than one call.</p><p>The problem was actually something I should have noticed from the start: zerbarize() does tr.addClass(klass).addEvents( &#8230; ); *but it doesn&#8217;t remove the style classes or events before doing so*, so each call to zebraisze() is just adding classes and event handlers rather than replacing the existing ones!</p><p>In the end, I used the following code:</p><p>var options = this.options, klass = pos % 2 ? options.cssEven : options.cssOdd;</p><p>// We might not know which class we have (if any), so check for either<br
/> if(tr.hasClass(options.cssEven)) {<br
/> tr.removeClass(options.cssEven);<br
/> } else if(tr.hasClass(options.cssOdd)) {<br
/> tr.removeClass(options.cssOdd);<br
/> }</p><p>// This is rather harsh, but provided the only events get added in zebraize()<br
/> // it should be safe enough&#8230;<br
/> tr.removeEvents();</p><p>//start the events!<br
/> tr.addClass(klass).addEvents(&#8230;.. etc&#8230;.</p><p>I can link you to a pastebin of the complete modified version if you&#8217;re interested.</p> ]]></content:encoded> </item> <item><title>By: Matt</title><link>http://davidwalsh.name/mootools-zebra-table-plugin#comment-11451</link> <dc:creator>Matt</dc:creator> <pubDate>Fri, 21 Aug 2009 13:51:27 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2168#comment-11451</guid> <description>Hmm it would be very cool if the zebratable are dynamically. A function for addRow or something like this :)I tried to make but without success :/</description> <content:encoded><![CDATA[<p>Hmm it would be very cool if the zebratable are dynamically. A function for addRow or something like this :)</p><p>I tried to make but without success :/</p> ]]></content:encoded> </item> <item><title>By: Elad Ossadon</title><link>http://davidwalsh.name/mootools-zebra-table-plugin#comment-9153</link> <dc:creator>Elad Ossadon</dc:creator> <pubDate>Thu, 07 May 2009 21:09:32 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2168#comment-9153</guid> <description>Nice!I would use &lt;thead&gt; for the headers and &lt;tbody&gt; for the data rows, and that way save the &lt;th&gt; check.</description> <content:encoded><![CDATA[<p>Nice!</p><p>I would use &lt;thead&gt; for the headers and &lt;tbody&gt; for the data rows, and that way save the &lt;th&gt; check.</p> ]]></content:encoded> </item> <item><title>By: David Walsh</title><link>http://davidwalsh.name/mootools-zebra-table-plugin#comment-9137</link> <dc:creator>David Walsh</dc:creator> <pubDate>Thu, 07 May 2009 13:04:06 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2168#comment-9137</guid> <description>&lt;p&gt;@Phil: Writing that in Moo would be just as short -- my class does much more than simple color every odd row differently.&lt;/p&gt;</description> <content:encoded><![CDATA[<p>@Phil: Writing that in Moo would be just as short &#8212; my class does much more than simple color every odd row differently.</p> ]]></content:encoded> </item> <item><title>By: Phil</title><link>http://davidwalsh.name/mootools-zebra-table-plugin#comment-9136</link> <dc:creator>Phil</dc:creator> <pubDate>Thu, 07 May 2009 12:55:44 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2168#comment-9136</guid> <description>This is way easier with jQuery if you want to follow the JavaScript route.eg: $(&quot;myTable tr:odd).css(&quot;background-color&quot;, &quot;#000&quot;); would colour the odd rows.</description> <content:encoded><![CDATA[<p>This is way easier with jQuery if you want to follow the JavaScript route.</p><p>eg: $(&#8220;myTable tr:odd).css(&#8220;background-color&#8221;, &#8220;#000&#8243;); would colour the odd rows.</p> ]]></content:encoded> </item> <item><title>By: Laust Deleuran</title><link>http://davidwalsh.name/mootools-zebra-table-plugin#comment-9113</link> <dc:creator>Laust Deleuran</dc:creator> <pubDate>Wed, 06 May 2009 14:07:34 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2168#comment-9113</guid> <description>@david: Why aren&#039;t you just using CSS3 nth-child selectors (http://tinyurl.com/czhlp2)? MooTools support CSS3, and zebra striping is quite easy with CSS3-selectors.I&#039;ve made a rough example with mootools here: http://ljd.dk/loot/mootables.html. I&#039;ve only tested in FF3, IE8 and IE8 compatability view, but so far it seems to works just like yours with less code.Maybe I&#039;m misunderstanding something, but imho it wouldbe easier to use CSS3 selectors. Thanks for a great blog!</description> <content:encoded><![CDATA[<p>@david: Why aren&#8217;t you just using CSS3 nth-child selectors (<a
href="http://tinyurl.com/czhlp2" rel="nofollow">http://tinyurl.com/czhlp2</a>)? MooTools support CSS3, and zebra striping is quite easy with CSS3-selectors.</p><p>I&#8217;ve made a rough example with mootools here: <a
href="http://ljd.dk/loot/mootables.html" rel="nofollow">http://ljd.dk/loot/mootables.html</a>. I&#8217;ve only tested in FF3, IE8 and IE8 compatability view, but so far it seems to works just like yours with less code.</p><p>Maybe I&#8217;m misunderstanding something, but imho it wouldbe easier to use CSS3 selectors. Thanks for a great blog!</p> ]]></content:encoded> </item> <item><title>By: Hiway</title><link>http://davidwalsh.name/mootools-zebra-table-plugin#comment-9101</link> <dc:creator>Hiway</dc:creator> <pubDate>Tue, 05 May 2009 18:45:49 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2168#comment-9101</guid> <description>@David Walsh: Thanks, David! That&#039;s OK. But, in your JS code you are working basically only  with &lt;tr&gt;-element, and almost the whole formating applying to this element. In that time, when in the list of definitions  we don&#039;t have general element for &lt;dt&gt; &amp; &lt;dd&gt; exept &lt;dl&gt;, but one list of definitions can have many &lt;dt&gt; &amp; &lt;dd&gt;, and exactly for these ones we need to apply a &quot;Zebra&quot; formating.</description> <content:encoded><![CDATA[<p>@David Walsh: Thanks, David! That&#8217;s OK. But, in your JS code you are working basically only  with &lt;tr&gt;-element, and almost the whole formating applying to this element. In that time, when in the list of definitions  we don&#8217;t have general element for &lt;dt&gt; &amp; &lt;dd&gt; exept &lt;dl&gt;, but one list of definitions can have many &lt;dt&gt; &amp; &lt;dd&gt;, and exactly for these ones we need to apply a &#8220;Zebra&#8221; formating.</p> ]]></content:encoded> </item> <item><title>By: David Walsh</title><link>http://davidwalsh.name/mootools-zebra-table-plugin#comment-9100</link> <dc:creator>David Walsh</dc:creator> <pubDate>Tue, 05 May 2009 18:20:49 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2168#comment-9100</guid> <description>&lt;p&gt;@Hiway:  Yep, you&#039;ll just need to modify the class to look for the proper XHTML tags.&lt;/p&gt;</description> <content:encoded><![CDATA[<p>@Hiway:  Yep, you&#8217;ll just need to modify the class to look for the proper XHTML tags.</p> ]]></content:encoded> </item> <item><title>By: Hiway</title><link>http://davidwalsh.name/mootools-zebra-table-plugin#comment-9099</link> <dc:creator>Hiway</dc:creator> <pubDate>Tue, 05 May 2009 18:18:00 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2168#comment-9099</guid> <description>Nice work! But, I have a question. Is this posible to make something like this for definitions lists? </description> <content:encoded><![CDATA[<p>Nice work! But, I have a question. Is this posible to make something like this for definitions lists?</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching 3/8 queries in 0.008 seconds using disk: basic
Object Caching 804/806 objects using disk: basic

Served from: davidwalsh.name @ 2012-05-23 10:54:09 -->
