Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Knockout js intellisense (autosuggest) not working for Webstorm and Visual Studio

I am using knockout js in my simple application. knockout js works fine in my application. My problems is why VS 2013 or WebStorm does not show any intellisense for knockout? Also it shows intellisense for jQuery.

Currently my codes is :

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <script src="Scripts/jquery-1.9.0.js"></script>
    <script type="text/javascript" src="Scripts/knockout-3.0.0.js"></script>
    <script type="text/javascript">
        $(function() {
            $("#jqueryTestId").html("Hello world, From jquery.");
        });
    </script>
</head>
<body>
    <div>
        name: <input type="text" data-bind="value: name"/> <br/>
        You've clicked <span data-bind="text: numberOfClicks"></span> times
        <button data-bind="click: incrementClickCounter">Click me</button>

    </div>
    <div id="jqueryTestId">

    </div>

<script type="text/javascript">
    var viewModel = {
        numberOfClicks : ko.observable(0),
        name : ko.observable(""),
        incrementClickCounter : function() {
            var previousCount = this.numberOfClicks();
            alert(this.name("TestName"));
            this.numberOfClicks(previousCount + 1);
        }
    };

    ko.applyBindings(viewModel);
</script>
</body>
</html>

In WebStorm it does not show any intellisense. But in VS 2013 it only shows ko in suggested list, but does not show observable function like:

ko.observable();

How I can enable intellisense?

like image 322
Seyed Morteza Mousavi Avatar asked Feb 01 '14 21:02

Seyed Morteza Mousavi


2 Answers

You just have to use the debug version of KnockoutJS i did and it autocompleted very well:

<script type="text/javascript" src="js/knockout-3.2.0.debug.js"/>

Knockout Debug Version

Hope this Fix your problem :)

Also this works well for "data-bind" tags: link

like image 116
Eefret Avatar answered Oct 20 '22 02:10

Eefret


Using knockout.d.ts configured as a javascript library in Settings/libraries/javaScript, as @RP Niemeyer has suggested, is the best solution for WebStorm. Using minified knockout-3.0.0.js as a library doesn't currently work - see WEB-10723

like image 23
lena Avatar answered Oct 20 '22 02:10

lena