【问题标题】:Aptana Studio: jQuery code completion/assist for variablesAptana Studio:变量的 jQuery 代码完成/辅助
【发布时间】:2013-05-11 18:39:50
【问题描述】:

我在最新的 Aptana 插件 (3.4) 中使用 jQuery 的代码完成/辅助时遇到问题。它似乎无法推断类型:

(function($) {
    $('p .test').each(function() {
        var $this = $(this);
        $(this).*DOES WORK*
        $this.*DOESN'T WORK*
    });
}(jQuery));

当尝试为 $(this) 创建的变量完成代码时,我没有得到任何帮助 :( 你有什么建议可以解决这个问题吗?

【问题讨论】:

  • var $(this) 是语法错误。您的意思是 var $this = $(this) 而不是 var $(this) = $this
  • 对不起,你是对的,我的意思是 var $this = $(this)。但这也不起作用。
  • 这里不是有用的东西吗? stackoverflow.com/questions/2458071/…
  • 您是否在 Aptana 中设置了项目性质?您可以通过“右键单击项目”->“属性”->“项目性质”来设置它们。如果您使用 PHP 库,您可以在此处设置“web”和/或“PHP”。并且你的项目目录中有 jQuery-scriptfile 吗?

标签: javascript jquery aptana code-completion code-assist


【解决方案1】:

答案如下:

(function($) {
    $('p .test').each(function() {
        var ele = $(this);
        $ele = $(this);
        $(this).*DOES WORK*
        ele.*DOES WORK*
        $ele.*DOES WORK*
    });
}(jQuery));

【讨论】:

  • 我不知道这是怎么回答的,但var this肯定是语法错误。
  • @JanDvorak 我忘了...谢谢:)! // 已编辑
  • 编辑注明。现在你正在泄露全局变量 ($ele)。
  • 感谢您的快速回复,但无法在全局范围内定义所有内容;-) 此外,$ele 和 ele 也不起作用。也许,您有不同的配置。我有 Eclipse Classic 4.2 (Juno) 和最新的 aptana 插件 (3.4.0.201304151542-7E7G-7MEMVKUHgFcLgFbkKoz0t-7)
猜你喜欢
  • 2013-07-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-20
  • 2013-11-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多