1,804 articles and 15,523 comments as of Monday, December 27th, 2010

Friday, November 7, 2008

Power User Toolbox: JavaScript for SharePoint – Pt2

In Part 1 of this series, you decided JavaScript will suit your needs. But if you want to work with JavaScript, you’ll need the proper gear.

Browser(s): Depending on your users, you may need several browsers for testing. Even more difficult, you may need multiple versions of those browsers. If you only need to test FireFox 3 and IE 7, I suggest grabbing the IE Tab add-on for FireFox which allows you to switch between the two browsers in the same window.

Browser Plug-ins: Most browsers have some sort of plug-in that allows you to “walk the DOM.” This can help you get started and keeps you from going insane while troubleshooting. My favorite is the FireFox add-on, FireBug. IE has one here.

Code Editor: you can write JavaScript in any text editor, but a little color-coding and “intellitext” can make your life much easier. Honestly, SharePoint Designer (SPD) does a pretty good job; and it’s probably already in your toolbox.

To start a new JavaScript file in SPD: File > New > Page, JavaScript

View all entries in this series: PaulGrenier-Power User Toolbox»
 

Please Join the Discussion

16 Responses to “Power User Toolbox: JavaScript for SharePoint – Pt2”
  1. Browsers: FF 2 is still popular with the FF crowd and it installs nicely along side FF 3. IE on the other hand doesn’t natively install side by side, but I found this (haven’t tried it myself)http://tredosoft.com/Multiple_IE?page=1 which allows you to run side by side.

    Plug-Ins: The IE is really buggy in IE 7. Works well in IE 6. I find the built in one in IE 8 is really good though.

    Code Editor: Cool. Didn’t know Designer had good support. As a developer type I like the support in Visual Studio… but for the power users I know they seem to like a product called Notepad++

  2. Isaac says:

    Have you looked at these JavaScript libraries and integrating them into SharePoint? I’ve done some integration with EXT and SharePoint, and while its not easy by any means, it can be very rewarding when you consider that some clients need to run firefox or safari. JavaScript helps out some of the cross browser compatibility issues.

    Another powerful JavaScript editor (free) is Aptana Studio. Supports for other types as well.

  3. Matt Moore says:

    I like VS better..Anyone attend PDC last week?

  4. Greg says:

    I was excited to see “Power User Toolbox: JavaScript for SharePoint – Pt2″ in my RSS. I then open up the article and find it’s a tiny, very short one. Was disappointed at first but having thought about this I think I might actually like the format – as long as new parts are published reasonably often :) . Sometimes seeing a long article I might add it to favourites (or more specifically the “ReadItLater” Firefox extension) but not actually read it as I know it would take me 30mins or more to read and fully digest the content. Small “nuggets of knowledge” like today’s article might actually be a good format. Something you can read and absorb in a few minutes… Interesting to see how this works out.

    Anyway, looking forward to the next article.
    Greg

  5. Isaac – I have integrated numerous javascript libraries into SharePoint including Scriptaculous for AJAX affects and LyteBox.

    Since javascript is nothing more than a basic text file, I create a ‘javascript’ document library at the top of the site collection. I then maintain the javascripts in those libraries and point to them using a Content Editor Web Part whenever I need the functionality.

    This works in WSS as well as MOSS.

  6. Greg – When Paul and I had lunch last week we talked about that exact subject. We want to present this material in digestible chunks so that you can test and cherry pick what you need without having to set aside an hour to run through everything.

    That’s also why we implemented the five star rating system for each article. We can quickly glance and see what is of interest and build more content using that as direct user feedback.

    As you can tell from Stump the Panel, Paul has been thinking a lot about how javascript can be used to give End Users access to functionality that would normally take serious design time on the back end.

    We’ll be doing a live, online javascript workshop in the very near future. Keep an eye on the Weekly Newsletter to get the first announcement.

    Mark

  7. Rich Finn says:

    Are there plans in a future part of this series to discuss using the jquery library in SharePoint? I’ve been using jquery in SP for quite some time now and since I started, my client-side potential of SP has exploded. jquery is easy to install, it’s simple to use, and the jquery site contains great documentation.

    Furthermore, I hear it’s going to be integrated into the next version of DotNet, so the earlier we learn it, the better we will be. Check jquery out at http://jquery.com/.

    Rich Finn

  8. Rich – Does jquery have to be installed at the server level, or can I setup a library and reference the scripts for the CEWP? — Mark

  9. Rich – I just looked at the site… simple script to store in a library and reference through the CEWP. Should be fun to play around with. — Mark

  10. Rich Finn says:

    Mark,

    Once bit of advice I’ve found with jquery. Instead of the file name they set the script file to when you download it, rename the file to be just ‘jquery.js’. This will help you later when they release a new version so you don’t have to go around and edit the script reference each place you use it.

    -Rich

  11. Rich – That makes sense, thanks. I’ve done that with LyteBox and Scriptaculous for the same reason. — Mark

  12. Christophe says:

    It would be interesting to have some performance information, especially when using Javascript libraries.
    The default SharePoint Javascript is already quite heavy (core.js, init.js, etc.), that’s why so far I have been reluctant to add a library on top of that.

    Christophe

  13. Rich Finn says:

    Christophe,

    Very true, but sometimes when wanting to do something on the client-side, a library such as jquery, which isn’t THAT big, is a nice option to have.

    From another angle, when building public-facing Internet WCM applications in SharePoint, you can block the SP JS references from loading for anonymous users, therefore decreasing the load times for the general public and allowing JS libraries to be leveraged without any impact on the site’s performance.

    -Rich Finn

  14. Christophe says:

    Rich, besides the standard library, are there any other jquery libraries or plugins that you would recommend as a good fit for SharePoint?

    Christophe

Trackbacks

Check out what others are saying about this post...
  1. [...] Power User Toolbox: JavaScript for SharePoint – Pt2 [...]

  2. SharePoint Kaffeetasse #98…

    Tools und Addons Custom Content Editor Web Part for SharePoint jQuery http://jquery.com/ jQuery is a…




Notify me of comments to this article:


Speak and you will be heard.

We check comments hourly.
If you want a pic to show with your comment, go get a gravatar!