2

I have multiple javascript files and they have their own functions. If I make reference one of them to inside any of them, it doesnt see its functions if the function is not prototype. What is logic inside the Intellisense ?

I want to use Splash function with Intellisense feature below, how can I do that ?

//My.js
/// <reference path="Test.js" />

.

//Test.js
NameSpace.prototype.UI = new function () {

    this.Splash = function (value) {
        try {
            if (value == 1) {
                $('#splash').css('height', $(document).height());
                $('#splashContent').css('top', $(window).height() / 2);
                $('#splash').fadeIn();
                $('#splashContent').fadeIn();
                setTimeout("SF.UI.Splash(0)", 3000);
            }
            else if (value == 0) {
                $('#splash').fadeOut(1000);
                $('#splashContent').fadeOut(1000);
            }
            else if (value == 3) {
                $('#splash').css('height', $(document).height());
                $('#splashContent').css('top', $(window).height() / 2);
                $('#splash').fadeIn();
                $('#splashContent').fadeIn();
            }
        } catch (e) {
            Splash(0);
        }
    }
}
1
  • so, does it not work if you have a reference on the page? according to this it should: blog.turlov.com/2010/05/… Commented Jun 23, 2011 at 10:55

2 Answers 2

3

JS Intellisense is flaky at best. Despite all those articles, in my experience, it doesn't work as advertised. I would suggest:

  • Make sure all your JS files are in the same project (making ti work across projects is even trickier).
  • Make sure /// <reference path="Test.js" /> is the very first line in JS.
  • Make sure there are no errors in the Test.js file (run JSLint on it to be sure) or use the vsdoc approach.
  • Look at the Output tool window to see if it contains any errors related to updating intellisense. This will help you troubleshoot and remove errors in your referenced JS file.

Alternative to create a Test-vsdoc.js file (this way, even if your main JS file has errors, it would not cause intellisense to fail) :

//Test-vsdoc.js
NameSpace.prototype.UI = new function () {

    this.Splash = function (value) {
    /// <summary>This is my function summary</summary>
    }
}

VS would automatically include it next time you restart the IDE (or try a force update Ctrl+Shift+J)

Sign up to request clarification or add additional context in comments.

Comments

1

Assuming that is the actual contents of your js file, including the //My.js comment, then that is your problem right there.

/// <reference comments must be at the very top of the file, before any other content, otherwise they will not work.

Side note, did you know there is a code snippet for that reference? its ref, then tab tab. Also you can drag / drop a file and get the comment.

Once you have your references done, you can force VS2010 to refresh your js comments by pressing Ctrl+Shift+J while editing the .js file

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.