Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • Thanks! One additional question - could you tell me some best practice how to use jQuery for SharePoint? as I understand the code from your answer have to be included in any custom web part. Am I right? Commented Jan 9, 2013 at 8:42
  • It actually depends, for the scenario when you create jQuery enabled web parts: 1) deploy JavaScript files for web parts into hive 2) reference it in web parts (provide reference to js file(s) in Render() method for Web Parts, for Visual web parts in ASCX User Control). Regarding code from example, yes, it could be reused, but i suggest not to embed it directly into web part, but to create separate js file and reference it in web part Commented Jan 9, 2013 at 10:24
  • 1
    Also, dont ever use the Jquery event binding for body onload. Its going to cause problems with Sharepoint. You should always use This Function (built in SP Function) to load your custom scripts: ExecuteOrDelayUntilScriptLoaded(checkJQuery, 'SP.UI.MyLinksRibbon.js'); Read more here : blog.fidelityfactory.com/2012/04/03/when-to-load-my-ecma-script Commented Jan 9, 2013 at 11:27
  • Can't you just replace $ with jQuery rather than declaring the $j variable? Commented Jul 1, 2015 at 15:11