About me
I live in Lund and work, well, at probably the best company in the world
Tag Cloud
Active Directory
AD
ajax
Android
api
app
Apps
ASP.NET
azure
C#
CAML
Chuvash
Client Object Model
codeplex
console
csom
csr
css
css3
database
devtools
extension
git
github
google chrome
html
html5
javascript
jQuery
jQuery tmpl
js
jslink
jsom
json
keyboard
keyboard layout
LINQ
linux
localization
log
masterpage
ModalDialog
monitoring
office365
onet.xml
Performance
Powershel
PowerShell
raspberrypi
REST
rättigheter
script
Serverinstallation
Sharepoint
SharePoint 2010
sharepoint 2013
sharepoint2013
sharepoint apps
sharepoint online
SP.js
spapp
SPField
SPList
SPListItem
spo
SPWeb
subversion
tips
ubuntu
VHD
Visual Studio
webpart
webparts
windows
xml
Top posts
Certiffications


Blog Stats
- 601,489 hits
Recent Comments
Blogs I Follow
- Daniel Chronlund Cloud Tech Blog
- Вула Чăвашла
- Discovering SharePoint
- Bram de Jager - Architect, Speaker, Author
- SharePoint Dev Lab
- GUID(E) To SharePoint
- SharePoint Dragons
- Mai Omar Desouki
- Cameron Dwyer
- paul.tavares
- Share SharePoint Points !
- Simple Stuffs
- Jimmy Janlén "Den Scrummande Konsulten"
- Aryan Nava
- SPJoel
- SharePointRyan
- SharePoint 2020
- Aharoni in Unicode
- ... And All That JS
- blksthl
I don’t like to use the noConflict method. This leads to confusion and is unobvious to use.
I would suggest create a closure function that have a local $ parameter :
this code:
$(function(){
$(“.someclass”).hide();
});
would become :
(function($){
$(function(){
$(“.someclass”).hide();
});
})(jQuery);
This case, there’s no conflict, because the local $ parameter is fed by the actual jQuery object.
HTH
steve
Thanks Steve! That’s correct. Today I would use a closure function for this. When I wrote this blog post for 1,5 years ago, I was quite new to javascript. Appreciate the heads up.
One of my pal highlight me that this construct should be enhanced like this :
var myjQuery = jQuery.noConflict(true);
(function($){
$(function(){
$(“.someclass”).hide();
});
})(myjQuery);
Without the noConflict call, jQuery will work, but the original SP’s $ won’t be restored to its correct value.
hth
Hi there! The issue you’re describing a fix for is causing no end of grief on our internal SharePoint site. With the solution you found from Brad Curtis — when I see the asset picker having these issues — I don’t see any other scripts using jQuery. Only cmssitemanager.js is making use of $(… stuff. Do I then need to find the cmssitemanager.js file and apply the fix within that? Many thanks!
Hi, you should never alter the built-in javascript files in SharePoint. What you should do is to use closures in your code, like Steve (above) says.
That’s cool, thanks. The closures method is a lot tidier too 🙂 So what might you suggest I do when getting this error but do not have additional / custom jQuery code running on the page? Or must there be something I can’t see lurking in there? Would appreciate any thoughts 🙂
@Matthew E Cornish: I think you misunderstood the issue. in the Sharepoint javascript file, the use of $ is not jquery, but a specific SharePoint object. And this is the root cause of the issue, because when a custom code want to use the $ alias of jQuery, it’s not jQuery, but the custom SP object. Either @Anatoly’s or mine solution will actually ensure that calls to $ will be on the jQuery object, and not the SP one.
Pingback: Does Sharepoint 2013 really have a jquery conflict with $? | Question and Answer