English 中文(简体)
How can Aptana show jQuery code assist for $ when jQuery is in no conflict mode?
原标题:

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?

最佳回答

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?

问题回答

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 $
  });
})();

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

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





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签