JavaScript Journal

Subscribe to JavaScript Journal: eMailAlertsEmail Alerts newslettersWeekly Newsletters
Get JavaScript Journal: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn


JavaScript Authors: Sematext Blog, Klaus Enzenhofer, Mehdi Daoudi, Yakov Fain, AppDynamics Blog

Related Topics: RIA Developer's Journal, SharePoint Archiving Journal, Microsoft Developer, JavaScript

JavaScript: Blog Feed Post

Use noConflict() with jQuery in SharePoint

JavaScript that powers SharePoint it too also makes use of the $ shortcut

I’ve seen quite a few posts on jQuery and SharePoint lately. I haven’t seen too many people point this out (maybe I didn’t search well enough :) ), so I thought I would take a quick minute to remind you to use jQuery’s noConflict() method in SharePoint. 

It appears somewhere in all of the magic JavaScript that powers SharePoint it too also makes use of the $ shortcut.  If you don’t simply having a reference to the jQuery script on a page can cause all number of things to break. 

I have seen it break my own JavaScript as well as cause certain things not to display such as the Edit Web Part pane.  The next time you want to use jQuery with SharePoint, just add the following code and you should be good to go.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script>

<script type="text/javascript">

  jQuery.noConflict();

</script>

Instead of using the $ to use jQuery methods you will have to use jQuery instead.  For example: $.get() would become jQuery.get().

Read the original blog entry...

More Stories By Corey Roth

Corey Roth, a SharePoint Server MVP, is a consultant at Hitachi Consulting specializing in SharePoint and Office 365 for clients in the energy sector. He has more than ten years of experience delivering solutions in the energy, travel, advertising and consumer electronics verticals.

Corey specializes in delivering ECM and search solutions to clients using SharePoint. Corey has always focused on rapid adoption of new Microsoft technologies including Visual Studio 2013, Office 365, and SharePoint.

He is a member of the .NET Mafia (www.dotnetmafia.com) where he blogs about the latest technology and SharePoint. He is dedicated to the community and speaks regularly at user groups and SharePoint Saturdays.