简体   繁体   中英

jQuery UI breaks Visual Studio 2015 Intellisense

I am finding a frustrating issue with JavaScript intellisense where if I include jQuery UI in my _references.js file I lose all JavaScript intellisense. Does anyone know if there is a way to fix this problem beyond removing jQuery UI from the _references.js ?

Update

  • I do know that more files in the _references.js file will cause it to slow down, that makes sense. However, I have projects at work which include far more files (on the order of 600) with no typesense issues, and my project has 20. So it's not a matter of "too many files."
  • I pulled my project from Git to a separate computer (therefore separate installation of VS15) and tried including the jQuery UI file and this still caused the loss of intellisense in my project.
    • It can't be an installation issue since other work projects include jQuery UI and there are no intellisense issues
  • I do realize that I can manually manage _references.js to accomplish the task, but I would like to fix it altogether since I hate needing to add information twice (create the JS file and then update _refernces.js ).

With this new information, I'm thinking it must be some type of deeper issue in my project's setup that is causing the issue as opposed to an installation based issue or jQuery UI specific issue. Does anyone have any ideas on what settings in a .sln or .csproj file might cause JS Intellisense issues?

For those who experience this issue, I found that using jQuery 3.x was causing instellisense to break when jQuery UI was included in _references.js . My solution was using NuGet to change back to version 2.2.4 and everything started to work fine again.

I've got the same problem. I tried quite a few things but the only thing I could get to consistently work was to disable the auto sync feature and remove the jquery UI reference. Intellisense also seems to slow down a good bit with more and more libraries, almost to the point it looks like it is not working. I finally just got to the point where I only include my own scripts and jquery for helpful reminders on syntax. Unfortunately this means I have to manually keep the _references.js file up to date but it's definitely better than it not working at all.

You can also limit your global references in the _references file and drag the script files that you want intellisense for to each view if you are like me where you have a script file for each view. That way you don't get intellisense for scripts that aren't even rendered to the view.

not sure if this will help you but have you added this to the top of your .js file?

/// <reference path="/scripts/jquery-3.1.1.js" />

that's the path that's made if you you've used NuGet to install jquery for your solution. If you've located your jquery file and intellisense file elsewhere use that path instead (I do believe they need to be in the same folder).

I found a better solution! Simple rename jquery-ui-1.12.1.js (or similar) to _jquery-ui-1.12.1.js . This will cause it to appear at the top BEFORE the conflicting jQuery 3 references in the _references.js file that cause intellisense to not work. Be sure to also update any script tag or BundleConfig.cs references you have to include the new underscore character prefix!

Solution:

In your _references.js file:

  1. Move the JQuery-UI reference above the main JQuery reference
  2. Disable auto-sync

such as:

/// <autosync enabled="false" />
/// <reference path="jquery-ui-1.12.1.js" />
/// <reference path="jquery-3.3.1.js" />

Drawbacks:

  • You will have to repeat step 1 every time you Update JavaScript References (right-click on _references.js to update references in Visual Studio).

在此处输入图片说明

Always install jQuery first any version you like and then install JQuery-ui. If you want to upgrade or degrade version of JQuery, you have to uninstall and again install JQuery-ui every time you do changes. First Jquery-3.6.0.js then Jquery-ui-1.12.1.js and you have to reinstall jquery-ui every time you make changes in jquery.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM