Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I want to use jQuery in my SP2010 hello world web part which pops up "Hello world" using jQuery. What do I have to do? I know I can do this with JavaScript, but I want to learn about jQuery in web part development.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

SharePoint Site doesn't support JQuery from scratch. You have to add it manually. It can be done in several ways:

Step 1. Adding JQuery :

1) Deploy JQuery as a custom feature.

Or

2) Upload JQuery as a simple file to the document library.

Step 2. Adding reference to the JQuery :

1.1) Create custom master page with reference to the JQuery.

1.2) Create web site based on the custom master page.

Or

2) Add Content Editor web part to the page. In the web part's properties specify the link to the file.

However to show Dialogue in SP 2010 you should use SP.js. Just add the reference to SP.js in the page and call SP.UI.ModalDialog.showModalDialog() function in JavaScript.

share|improve this answer

I am not sure what you're going to learn by doing this over and above just using jQuery on a non-SharePoint html page but...

  • Go to a web part page or wiki page you've setup.
  • Select Site Actions > Edit Page Click "Add a web part"
  • Select Media and Content > Content Editor
  • Select “Click here to add new content” On the ribbon select Html > Edit HTML Source

Sp2010 Foundation CEWP Edit HTML Source

Then paste the javascript/jquery you want to put on the page.

To get inspiration on what you can do with javascipt and SharePoint start with Christophe's blog + see also JQuery Tutorials site

share|improve this answer
    
JUST an FYI...New Content Editor WebPart (2010) strips out all the script added to the HTML source. Only Option left is to create a htm or txt file in any doc lib and link the Content Editor WebPart to it. –  Vamsi Jul 5 '11 at 14:40
    
No it doesn't. If you try and put script directly into a wiki page (even when using source) then yes it will - but if you put it into a CEWP it does't. Don't take my word for it - sympmarc.com/2011/03/29/… –  Ryan Jul 6 '11 at 11:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.