tag:blogger.com,1999:blog-30404818.post2057517090239306992..comments2023-09-11T05:58:23.458-05:00Comments on Web Dev .NET: ASP.NET MVC & jQuery Part 2: Zebra StripingTesthttp://www.blogger.com/profile/14667340517136058696noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-30404818.post-56112908994679254972009-07-01T03:38:22.106-05:002009-07-01T03:38:22.106-05:00That can be done with CSS selectors without having...That can be done with CSS selectors without having to use Javascript. Most recent versions of all major browsers implement this feature.Timnoreply@blogger.comtag:blogger.com,1999:blog-30404818.post-61103636875350576662009-06-30T16:43:12.201-05:002009-06-30T16:43:12.201-05:00"Wow, I hadn't thought about it that way ..."Wow, I hadn't thought about it that way before. Good write up,<br />>> very clearly written. Have you written previously about "Zebra Striping"? I'd<br />>> love to read more."Unknownhttps://www.blogger.com/profile/00038973050531230032noreply@blogger.comtag:blogger.com,1999:blog-30404818.post-69492280760551573302009-06-30T10:43:58.470-05:002009-06-30T10:43:58.470-05:00I am going to have to strongly disagree with this ...I am going to have to strongly disagree with this article.<br /><br />The original way that you were handling the styling of the tables - before you learnt jQuery - was much superior for both the user experience and from the point of view of code simplicity and maintenance.<br /><br />It is generally best practise for front end development that:<br /><br />> HTML handles the structure and content of the document,<br /><br />> CSS handles the presentation,<br /><br />> and Javascript handles adding behaviours.<br /><br />What we are dealing with here is the presentation of a table, therefore we should only be reaching for Javascript as a last resort. As long as the structure of the document is correct then this effect can be completely achieved using simple CSS. <br /><br />There no need to use Javascript let alone jQuery. The disadvantages of a javascript solution are:<br /><br />> <b>Increased page weight.</b><br /><br />> <b>Slower page rendering.</b> - the styles will not be displayed until the JS has downloaded and been processed. (This could be very significant to mobile users)<br />> <b>More complicated code</b> - if the classes are not it the source code it may require knowledge of the JS functions to write the CSS. And the JS function itself is much more complicated than a simple if() statement in the .aspx file.<br /><br />So what are the advantages of this method? It seems that the advantages are slightly cleaner .aspx file. In my view this isn't worth the trade.<br /><br />I think it would be helpful to see the view as the combination of the .aspx files, the CSS and the Javascript. This way when you consider "want[ing] to keep our Views in MVC as simple as possible" you'll be considering the system as a whole and won't be tempted by false economies in one technology at the expense of the others.<br /><br />It's worth noting that all modern browsers except IE6 will allow your to add a hover psuedo class to tr elements. This removes the need for adding the events to each row of the table. Adding these events to a large table would be very likely to cause significant delays in the page display. If you need the hover effect for IE Javascript is the only option, but it would be much more efficient to use event delegation - I would recommend simply not providing this effect for IE6 users though.edeveretthttps://www.blogger.com/profile/07201757043725798161noreply@blogger.com