The Blog
Web Designers vs. Web Developers Infographic
While working in the industry for a few years, I find that stereotypes do exists. Of course they always will exist and yet they aren’t always applicable. But for good fun, I’ll post this here, Enjoy!
Thanks to @shanesnow for his wit and perspective used to create this!
Click for a larger imageWhy jQuery won’t fire in IE7
JQuery is a Javascript library which has grown to have a huge following among web designer’s and developer’s. The main advantage to using a Javascript library like jQuery is that you don’t have to be a Javascript wizard to implement, powerful Javascript techniques into your web projects. But for those (like me) without a big background in Javascript it can be a fun learning experience to get some seemingly simple jQuery running.
After implementing a jQuery carousel developed by Jan Sorgalla, an example can be seen here I ran into a small issue. The jQuery plugin worked great in all browsers, EVEN IE6! but for some reason in IE7 the script wasn’t firing.
After extensive searching into deeper and deeper pages of Google results I found a small post outlining the problem.
Comma’s kick my butt.
Most jQuery plugins offer customization via different parameters which can affects how the Javascript functions on the page. In this case I was passing the parameters you see below, you can see my error highlighted on line 7.
The Error
jQuery('#mycarousel').jcarousel({ vertical: false, scroll:1, initCallback: mycarousel_initCallback, auto:5, animation:700, wrap:'last', });
Just like CSS selectors, when you use multiple selectors you need to place a comma after each selector which is followed by a subsequent selector. Like so..
Just like CSS
.sf-menu li, .sf-menu li:hover, .sf-menu li.sfHover, .sf-menu a:focus, .sf-menu a:active { background-color:transparent; }
But when the final selector, or in the case of jQuery, the final parameter is listed it should not be followed by a comma. CSS breaks immediately when you do this, so it’s not a hard time to troubleshoot. But most modern browser’s and even IE6 handle this error when it’s passed with Javascript. But IE7 doesn’t. It breaks, and when all else is working, it can be hard to track down this issue.
The correct code for the parameters above should read..
The Right Way
jQuery('#mycarousel').jcarousel({ vertical: false, scroll:1, initCallback: mycarousel_initCallback, auto:5, animation:700, wrap:'last' });
I hope this will alleviate some headaches for the jQuery beginner out there. See you next time!
12