3

Example jscript:

    var aGlobalVar = 1;

    function aFunction(){
        aGlobalVar = 2;
    }

    function anotherFunction(){
        var aLocalVar = 3;
        //insertion point here
    }

If I'm typing in anotherFunction() as indicated, and I press Ctrl+SPACE, the content assist box contains neither aGlobalVar nor aFunction(), but it does give me aLocalVar. Any ideas why this happens? I've tried many javascript editors, and Netbeans is my favorite, except for this one issue. I'm using Netbeans IDE 7.0

Edit: interestingly enough, everything does show up properly in the Navigator panel. some screenshots: enter image description here enter image description here enter image description here

1 Answer 1

2

When you hit Ctr+Space on an empty line, NetBeans offers you a list of most likely variables and functions you may want to use. These are local variables for the context, and after a horizontal line, another most likely list, and a note at the top, that some results are omitted.

If you add further characters, your global may very well show up.

enter image description here

Edit: wrapping the code in an immediate function solves it, well sort of :)

(function () {

    /* ... */

})();
Sign up to request clarification or add additional context in comments.

5 Comments

thanks for the answer. please look at my screenshots I added. maybe it has something to do with how you created the js file. are your js files part of any project or completely isolated?
They are part of a php project yes. I also noticed that out of project files don't have any autocomplete. I recommend creating projects for your codes, even for one file, since NetBeans expects you to do this.
Same for me, in out of project files globals cannot be seen in autocomplete. Shame. :( Also it is funny since Navigator window shows that it knows them.
thanks! that worked. only problem is that I'm writing javascript for a Windows 7 gadget, and I don't really want a php project zipped up inside my gadget, but thanks anyway
About that part, you can tell NetBeans to store nbproject out of your project, so it won't get in the way. Good luck with your gadget!

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.