February 22, 2012

Parsing the Sharepoint Site Actions menu with jQuery

On recent Sharepoint (WSS3) sites I use jQuery extensively.  One of the things I often do is to remove the default Site Actions menu and draw those same links at the bottom of each page in the site.  I had found a way to successfully parse the Site Actions menu using some trickery:

$(‘#siteactions ie\\:menuitem’).each(function(){

(Note: my Site Actions Menu lives in a div called #siteactions in my master page)

This seemed to work well until I wanted to take advantage of the latest SPServices release which is now compatible with the latest jQuery.  I suspect (though I haven’t done extensive testing to be sure) is that some of the same issues with the new jQuery that were incompatible with the earlier release of SPServices were causing my issues.  After a bit of head-scratching I decided to sidestep the issue alltogether.  I couldn’t quite find a way to select the ie:menuitem nodes and step through them with an ‘each’ so instead I opted to simply use:

$(‘#siteactions menu’).children().each(function(){

I suppose this may have been obvious to some but for some reason I was determined to get the selector right.  If you know how to select elements with namespaces across-browsers in jQuery 1.7 I would be very interested to hear.

 

 

MisFire(fox)

If you are having difficulty with Firefox kicking off two events simultaneously and not happening in other browsers, the issue may lie with your $(document).ready or $(window).ready events.  Normally it isn’t a problem to have multiple .ready blocks on your page.  However, I ran into a pesky bug today that only affected Firefox.  Consolidating my initialization scripts into the same $(window).ready() block cured the problem.  This wasn’t ideal since I wanted to keep that code in a separate file, but the fix worked.

Accessing web services in Sharepoint with jQuery

Sharepoint can be a very useful collaboration tool but if you are stuck with WSS instead of MOSS you might find yourself wishing you could do more.

Your organization probably won’t let you just start coding up .NET and sticking it anywhere you want in your site.  So if you are looking to enhance your user’s experience, you might want to look at this jQuery JavaScript library that allows you to access Sharepoint web services.

A couple of scenarios I have used this for include retrieving attachments for list items and seeing if a user had a record in a particular document library.

This really just hits the surface of what this could do for you.  You can even use CAML to build queries to pull custom data sets.

Coda style popup bubbles

I found these recently thanks to a link from Adam Walker and had to share.  I have needed popup bubbles or tooltips from time to time over the years and this has to be one of the most elegant solutions I have seen.

picture-2

Check out how to create these for yourself over at jQuery for Designers.  They provide detailed instructions and even a screencast.