Frage

Currently my intellisense in visual studio is working for things like $(this).hide etc. But for the code below it is not working when I want to pull op for example the ajax, serverside and columns. When I press ctrl-space I get no options that I could add. I'm unsure what is causing this? Is this not supported or do I need to configure something?

$('#example').DataTable(
        {
        serverSide: true,
        ajax: 'GetUsers',
        columns: [
            { data: 'Id', visible:false,sortable:false},
            { data: 'UserName' },
            { data: 'EmailAddress' }
        ]
    });
War es hilfreich?

Lösung

Visual Studio uses commented XML-like markup to build javascript intellisense.

Basically, you add markup of this form (say this code is in myScript.js):

function myFeature (enable) {
    /// <summary>Summary of the function</summary>
    /// <param name='enable' type='Boolean'>True: RW, False: RO</param>

    [function code here]
}

In this example, you can see the parameter enable is declared as a boolean, you will get intellisense accordingly.

There are numerous tags you can use: <summary>, <param>, <field>, etc.

You can find documentation on MSDN.

To access this intellisense from another script file, you will need to add a reference as Dean.DePue said (/// <reference path="~/Scripts/myScript.js" />).

Now back to your problem

DataTable does not provide in its script file markup to describe to visual studio how things work inside of it. Visual Studio is still able to get the functions available, but no additional info is found.

Note that you can also provide this markup in a separate file (often called a vsdoc file). It allows for us to embed minified files but still get the intellisense by using the // <reference> that points to the vsdoc file.


To sum it up

DataTable does not provide intellisense info (and does not have a separate vsdoc file), that is why you don't get anything.

As per the animate function, the first parameter is declared as type=Object, so it can be any object without further detail.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top