jQuery Intellisense in Visual Studio 2010

kmcbrearty
kmcbrearty used Ask the Experts™
on
I downloaded the files for the latest version of jQuery:

jquery-1.7.2-vsdoc.js
jquery-1.7.2.js
jquery-1.7.2.min.js

I have tried methods from several different articles that I have read to attempt to get intellisense to work but no matter what I do it will not work.  I have tried it in a standard page as well as a master page without any luck. All three files are located in a "js" folder.  The code that I am currently working with is:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
      <!-- insert the script to reference jQuery here -->      
      <script src="../js/jquery-1.7.2.js" type="text/javascript"></script>
      <!-- insert the script to display the Hello World message here -->
      <script type="text/javascript">
          $('document').ready(function () {
              alert('Hello World!');
          });
      </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    </div>
    </form>
</body>
</html>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Jon NormanInformation Systems Manager
Top Expert 2012

Commented:
the $('document') should be $(document):

$(document).ready(function () {
    alert('Hello World!');
});

Open in new window


if that still doesn't work, do you have any errors in the error console?

if still no joy try using the following source of jQuery
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js">

if that still doesn't work try:

<script type="text/javascript">
  alert("jQuery: " + typeof(jQuery)+"\n$(document): " + typeof($(document)));
    $(document).ready(function () {
      alert('Hello World!');
     });
</script>

Open in new window

and let me know what the alerts say

Author

Commented:
I do not have a problem getting jQuery to work on the page.  My issues is that I can not get intellisense to work as I try to use it.  

As for the alert it states "jQuery: function $(document): object".
Ok, I was able to determine that my primary problem was an option that wasn't set correctly.  Under Tools --> Options --> Text Editor --> JScript --> General --> statement Completion --> Auto List Members.  After making this change I still was not able to get intellisense to show up for the jQuery methods until I added the following code.

    <script src="js/jquery-1.7.2.js" type="text/javascript"></script>
    <script src="js/jquery-1.7.2-vsdoc.js" type="text/javascript"></script>

Open in new window


After adding this code I was able to remove the reference for the documentation file and Visual Studio was able to find the file.  I suspect that restarting Visual Studio would have done the trick as well.  At any rate I now have everything working as expected.

Author

Commented:
These were the steps that I took to solve the problem.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial