evoke it logo white with clear backQuick Contact

jQuery only working in edit mode on a SharePoint 2013 site

jQuery only working in edit mode on a SharePoint 2013 site

What to do when your jQuery won’t work after you save it? You need look no further; here at Evoke IT we have that little piece of code that will save the day.

Whilst setting up a SP2013 site page on a client’s site we discovered that we were unable to get jQuery working on the page.

 

When creating an image banner slideshow using jQuery we found that when in edit mode the jQuery would work as expected and the image banners would fade through one after another. However when saved, the jQuery would no longer work and it was just the static version of the first banner image…

…After a bit of digging around we discovered the solution! In order to get your jQuery code working when you’ve saved the page you need to wrap all your jQuery code within the below code.

(function($){

// my jQuery code was placed here `$`,

})(jQuery);

It has been suggested that there is possibly some code elsewhere in SharePoint which is over-writing the usual jQuery code but wrapping it as per the above seems to resolve this issue!

And it’s as easy as that!

Be the First to Get Our Ebook
Microsoft SharePoint 2019

What you need to know!

Back To The BlogContact Support

View Post's Via Catagory

IT support laptop image
Software Development cloud image
Terms & ConditionsPrivacy PolicyDeveloped by Evoke IT