You are visiting the High Monkey blog archive. Posts prior to 2016 may not meet accessibility standards. Please visit our current blog area at https://www.highmonkey.com/blog to view accessibility compliant blog posts published since January 1, 2016.

Stupid Usability #41

Client Code Quandary

Written By: High Monkey
Posted: 4/7/2014

From the mind of Chad Heinle, Senior Consultant at High Monkey:

Caution: this post is going to be for the technically minded, so hold on to your hats.
 
To be fair, I’ve only been using jQuery for the past couple of years seriously, and not all that frequently. There are a lot of plugins out there, and as with any code, they all have to play in the same sandbox. The jQuery library is a great tool for writing client side code, but recently I came across an error that I have never seen before.



 For those of you who have worked with jQuery enough, you may have run up against this very issue. In writing jQuery code, typing a dollar sign ‘$’ or ‘jQuery’ is how to reference the library. The dollar sign is a short-hand expression available and much appreciated by fast-typing client-side developers such as myself. Recently, I had written some code on a stand-alone page, tested it, and then moved it into a site we’re currently developing. My code no longer worked and instead just threw the error above. The Google troubleshooting search proved easy enough to find what the answer was, but that lead me to the question: why provide code that lets you make code not work?
 
The issue lies in a jQuery call called ‘noConflict()’. You may use this in any jQuery script to release the ‘$’ from its assigned duties and use it as a different variable. Herein lies the problem: if you are using multiple script files or plugins, the ‘noConflict()’ call in one script will break another script because it is using ‘$’ instead of ‘jQuery’. The error message does not pinpoint that there is a noConflict call somewhere, so I was left to hunt for it through multiple scripts.
 
There are a few ways to resolve the issue, though the easiest is just to go through and replace all of your ‘$’ calls with ‘jQuery’ – a simple find-replace. There may be some explanation or historical reason for this to be included, but for now I am left scratching my head and wondering why jQuery can break jQuery on purpose.

Chad's Bio Coming Soon!

More About Virgil

Virgil Carroll is the owner and president of High Monkey – based in Minneapolis Minnesota. Virgil also wears the multiple ‘hats’ of Principle Human Solutions Architect and SharePoint Architect.

Virgil is one of those rare individuals who can dive deep into technical topics while speaking clearly to the business owners of a project and never forgetting that the end user experience has the highest priority. He calls it using both sides of his brain. Virgil is passionate about leveraging technologies ‘out of the box’ as much as possible with a focus on the strategic use of content to create websites that deliver the right content to the right audience on the right device at the right time. Virgil brings high energy, an ironic wit, and a sense of grounded perspective whenever he speaks to an audience. Virgil regularly speaks at conferences and user groups throughout the United States and occasionally in Europe.

Posted: 4/7/2014 12:00:00 AM by Brian Haukos | with 0 comments