Monday, November 8, 2010

Using jQuery in SharePoint 2010? Here is something you didnt expect!

If you are planning or using jQuery JS library in SharePoint 2010, there is one thing you didn't plan - for sure.
The $ sign from jQuery library is conflicted with the $ sign used in SharePoint JS - only in picture library "thumbnails" view.
Meaning, your code will not work if it has a picture library thumbnail view web part.
A wrong solution would be to append your JS to the end of the page - do this and your code will work, but the thumbnail view will stop working!
The solution for this is rather simple and annoying,
All you have to do is rename the $ sign into something else, like myJQ.
To do this - add this simple line of code at the end of your jQuery JS file:
var $jq = jQuery.noConflict();
and use $jq instead of $.
Note: you should use your own unique key instead of $jq.

1 comment:

Baris Bikmaz said...

You should use the construct

var $j = jQuery.noConflict();
$j("#id")....