I was using jQuery to style some elements in a SharePoint 2010 site. Then it came to my notice that none of those styles where visible on Picture Libraries (except when the thumbnails view was active). And I was also getting a JavaScript error on the page: “’null’ is null or not an object”. It was working perfectly everywhere else on the site.
I tried debugging the JavaScript file, changed a lot of stuff, removed code, but nothing worked. I was still getting an error in that file:
Then, after a lot of head scratching, I tried moving the script declaration, on the master page from the head to the end of the code, right before the end of the body tag.
And it worked. Still haven't figured out what was the problem there, but at least I know how to fix it ;)
I recently discovered why this was happening. The dollar ($) keyword used in jQuery was in conflict with the default SharePoint scripts. So instead of using the short name version $ use the full name version jQuery. So jQuery(“body”) instead of $(“body”).