Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Netbeans autocompletion not fully working with current jQuery.js (v1.8.0)

I just started using netbeans (NetBeans IDE 7.2 (Build 201207171143) under Win7/64bit) to try out jQuery developement. Especially the autocompletion seemed very handy..

I used this tutorial: http://netbeans.org/kb/docs/web/js-toolkits-jquery.html I did everything like in this tutorial but took the current version of jQuery.js (v1.8.0) instead of the older 1.4.2-revision.

Lets look at the following code snipped:

<script type="text/javascript">
  $(document).ready(function(){
    $("h1").click(function(){ alert ("HI!"); });
  });
</script>

The autocompletion works for "$(document)." and suggests "ready". So far, so good...

The 3rd line starts with "$("h1")." after that selector followed by "." I get a lot of suggestions but not for "click"; When I use the older jQuery-1.4.2.js it works as seen in the following screenshot of the tutorial: http://netbeans.org/images_www/articles/69/web/js-toolkits-jquery/code-completion.png

Questions:

  • What's actually the problem here?
  • Can we somehow get this working with the current version of jQuery? If so: How?
  • Who's potentially in charge here ... bug in jQuery or netbeans?

Regards, Stefan

--- update ---

The problem only occurs if you add a <script type="text/javascript" src="js/jquery.js"></script> to the source code. If you omit the include, it's working as it should. So this seems to be an issue of Netbeans. And lead us to the following adapted question:

Question: Not including the jquery.js is just a workaround. Is there a way to fix that? Maybe it's needed that we disable some "auto-include-everything" option somewhere in the project?

--- update #2 : SOLUTION ---

It's even the name of the included script <script type="text/javascript" src="jq.js"></script> works, but any resource name ending in 'jquery.js' don't work, whereas <script type="text/javascript" src="jquery-1.8.0.js"></script> worked! So it's actually a kind of bug in Netbeans, that is caused by some hardcoded stuff. And the solution is to rename the JavaScript file in a way that it e.g. still includes the revision.

like image 392
SDwarfs Avatar asked Aug 14 '12 15:08

SDwarfs


1 Answers

Looks like you're using a minified version of jQuery, because you're likely getting code completition from JS core, so you need to include in your project the development version or both (development and minified), if you're pushing code to production, to get jQuery code completition and API especifications. Watch this:

jQuery 1.18 code completition demostration

like image 155
tuxtitlan Avatar answered Sep 28 '22 18:09

tuxtitlan