Quantcast
Channel: Marc D Anderson's Blog » jQuery library for SharePoint Web Services
Viewing all articles
Browse latest Browse all 109

But Is jQuery Already Loaded?

$
0
0
JQuery
JQuery (Photo credit: Wikipedia)

Many end users are taking advantage of all of the goodness that jQuery provides, whether by adding simple effects like a sliding Quick Launch, more sophisticated form enhancements like SPCascadeDropdowns from SPServices, or even writing their own scripts for more complex solutions. More than ever, the distinction between “end user” and “developer” is blurring. IMO, that’s a good thing, but it also introduces complications, of course.

As one of those end users, you owe it to yourself to talk to your SharePoint team to explain what you are doing and to find out if jQuery is already loaded in the environment. In many cases, it will already be loaded in the master page or a page layout so that it is readily available across the Site Collection. The version that is loaded can also have an impact on how plugins function, making some of them effectively useless if there’s a version mismatch.

I know that in some cases, even finding the person who might know what’s loaded in the master page or what the plans may be is well nigh impossible. In those cases, here’s a trick to find out what’s up.

In a Internet Explorer browser window with the page you want to work with open, hit F12 to open the Developer Tools, and go to the Console. The screenshot below is from IE9, where there is a separate Console tab:

SNAGHTML562e339

If you’re in IE8, the Console is hidden under the Script tab, as below.

SNAGHTML5632086

If you’re in an older version of IE, well, I don’t have a screenshot for you. You may also not have the Developer Tools available, as it was a separate download with IE7 and below.

In Firefox, you’ll need the firebug add-in. If you have it, you can hit F12 to open Firebug. The Console tab is the first one on the left:

SNAGHTML56920f4

Once you’ve gotten to the Console, wherever it is, type the line I show in each of the screenshots above:

jQuery.fn.jquery

Depending on where you are, you’ll then either hit enter or click on the Run button.

Somewhere on the screen, you’ll see a display like this one, which shows that jQuery version 1.7.1 is loaded…

SNAGHTML56b32de

…or you’ll see something like…

SNAGHTML56d0846

…which tells you that jQuery isn’t loaded at all.

At that point, at least you’ll know what you are dealing with. If the version number isn’t what you need (I sometimes still see jQuery 1.3.2 loaded in a master page, which is ancient) then you’ll need to talk to your SharePoint team about updating it.

Tip ‘o the skimmer to Matt Bramer (@ionline247) for the exact syntax…

@ @ type in the console: jQuery.fn.jquery; ~ Give version num and tests whether or not it's loaded.
@iOnline247
ɹǝɯɐɹq ʍǝɥʇʇɐɯ【ツ】

…and @BinaryJam for asking the question in the first place!

something I'd love to see in getting started with jQuery articles ".Go view the source of the page, your devs may have already included it"
@BinaryJam
Binary Jam
Enhanced by Zemanta

Viewing all articles
Browse latest Browse all 109

Trending Articles