Adding additional js files breaks jQuery IntelliSense

前端 未结 6 1208
名媛妹妹
名媛妹妹 2021-02-04 15:22

I have been using jQuery IntelliSense in VS2008 and it has been great. Recently I added a reference to jQuery UI and since then, the jQuery IntelliSense has went away. I found

相关标签:
6条回答
  • 2021-02-04 15:30

    The accepted answer helped me fix this issue but didn't resolve the problem. I installed the hotfix: http://code.msdn.microsoft.com/KB958502 but was still receiving an error.

    Error:

    Error updating JScript IntelliSense: D:\Dev\Test\Scripts\jQuery-1.3.2-vsdoc.js: 'jQuery.support.htmlSerialize' is null or not an object @ 1430:4
    

    It appears the addition of the follwing file without the appropriate -vsdoc.js file causes the above issue.

    <script src="../../Scripts/jquery-ui-1.7.custom.min.js" type="text/javascript"></script>
    

    I added an empty file "jquery-ui-1.7.custom.min-vsdoc.js" to my scripts folder and the Jscript Intellisense issue went away.

    0 讨论(0)
  • 2021-02-04 15:31

    If there are errors in any refernced files it will break intellisense for all files references from the same document. The next version of Visual Studio is going to be much more robust in this respect. I apologize directly for this fragility. We made some design decisions early on that we prevented us from making VS9 external references more robust.

    In the meantime, use the following workaround. Install SP1 from the link Slace gave you. If you have a reference a file named .js and there is a file named -vsdoc.js in the same location, then JS intellisense will pick up the -vsdoc version. If that script is empty then it won't generate an error. Identify the jquery plugin that is causing intellisense generation to fail and place a -vsdoc version next to it. You won't get intellisense for UI, but you will still get jquery and other plugins that do work.

    Anything you put in the vsdoc version will show up in intellisense. You could put spoofed versions of the data structures that you want to display in intellisense if you want to.

    0 讨论(0)
  • 2021-02-04 15:33

    I'd like to present a slightly better solution. A few months ago I tackled this problem and created a very basic vsdoc file for jQuery UI. Here's the link to the blog post (which has the file for download).

    0 讨论(0)
  • 2021-02-04 15:39

    It's likely that there's a bug in one of the subsiquiently referenced JavaScript files. Open your JS file and once the "Updaing JavaScript Intellisense" has gone from the status bar of Visual Studio (there is a menu option which will force the JS intellisense to refresh, don't remember where it is, I just created a keyboard shortcut via the Tools -> Options -> Keyboard area) open up your Errors window and under the Warnings you should find the reason why the intellisense has failed to load.

    It's generally a bug found when parsing one of the files but I have had stack overflows when I had a lot of files referenced.

    Edit: You also should make sure you have this VS patch installed: http://code.msdn.microsoft.com/KB958502 and VS 2008 SP1 (install SP1 first!). Then you just need to have:

    /// <reference path="/path/to/jquery-1.3.1.js" />
    

    Ensure that you maintain the -vsdocs on the intellisense file and it will be automatically picked up (as long as it's in the same folder as the file you reference)

    0 讨论(0)
  • 2021-02-04 15:40

    Great, the tweak is by creating an empty *-vsdoc.js file for each troublesome *.js files.

    I found this error caused by anonymous function e.g. like this:

    (function($) {
        $.anything...;
    })(jQuery);
    

    Hope this caused will help somebody creating the http://code.msdn.microsoft.com/KB958502 and JScript IntelliSense Team.

    0 讨论(0)
  • 2021-02-04 15:51

    I solved this per the advice above with a minor extension: the trick for me was to add a reference on my page to both my jqueryui.com library AND to the blank -vsdoc.js version of the file I created:

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

    Hope this helps!

    0 讨论(0)
提交回复
热议问题