views:

1153

answers:

4

When I'm using jQuery in no conflict mode I still like the convenience of the $ object so I tend to structure my jQuery like:

(function($) {
    //Now I use $ instead of jQuery
    $(document).ready(function(){ 
        //some code in here etc
    });
})(jQuery)

But this seems to break code assist, it works for the jQuery object but not the $ object. Is there any way to configure an Aptana project to handle this?

A: 

One way to go about this would be to leave out the closure call during development. And implement it at release.

roosteronacid
That might work, but I'd rather have my local code remain identical where possible
benz001
Aye. But if you structure your code neatly, it shouldn't be _that_ big of a problem.
roosteronacid
A: 

wrapping it in a private function should be enough. You can try this as well:

(function() {
  var $ = jQuery.noConflict();
  $(function() {
    // do stuff on DOM ready using $
  });
})();
David
Good suggestion but my Aptana (v1.5.1) still can't seem to resolve the Doc scope using this structure
benz001
A: 

This works - but is a bit ugly:

Create a second dummy project based on jQuery with the Aptana wizard, while the second project is open, the first will show CodeAssist.

Then add some ScriptDoc as follows to get around the noConflict issue

(
/** @param {jQuery} $ jQuery Object */
(function($) {
     //Now I use $ instead of jQuery
    $(document).ready(function(){ 
        //some code in here etc
    });
})(jQuery)

There must be something I don't understand about ScriptDoc integration and Aptana - any other suggestions?

benz001
A: 

This Helps me:

Install code support for jQuery (Aptana 1.5.1)

First of all, install the plugin "Aptana Support for jQuery". Go to Help > Install Aptana Features > Ajax libraries and check jQuery Support. Restart Aptana when prompted. Procedure is the same for Windows and OSX.

Follow the following steps:

* (Windows) Click Window > Preferences
  (OSX) Click Aptana Studio > Preferences
* Expand Aptana
* Expand Editors
* Expand JavaScript
* Click on Code Assist and check jQuery (current version 1.3.2)

Note: you must install the support plugin first.

Source: http://www.squaresoft.se/blog/jquery-code-assist-aptana-studio

Markus
Thanks Markus, wasn't enough though because of the jQuery no conflict - adding /** @param {jQuery} $ jQuery Object */ seems the best solution so far
benz001