javascript - Rails 3.1 是否包括整个 jQuery 库?

标签 javascript jquery ruby-on-rails-3.1 coffeescript asset-pipeline

我真的很困惑,因为我试图在 coffeescript 中为 rails 3.1 编写一些 jQuery 教程,但似乎 jquery 的动画功能都不起作用。

例如,这什么都不做:

/assets/javascripts/my_controller.js.coffee:

$(document).ready ->
  $('p:first').fadeIn()

但是,如果我这样做:

$(document).ready ->
  alert($('p:first').text())

我确实得到了正确的文本。谁能告诉我这是怎么回事?

谢谢大家,感谢 Trevor 读懂了我的想法。感谢 Benoit 帮助我正确使用该网站。我的最终答案如下。

最佳答案

我仔细研究了一下,发现了这个:(来自 http://api.jquery.com/visible-selector/)

Elements with visibility: hidden or opacity: 0 are considered to be visible, since they still consume space in the layout. During animations that hide an element, the element is considered to be visible until the end of the animation. During animations to show an element, the element is considered to be visible at the start at the animation.

How :visible is calculated was changed in jQuery 1.3.2. The release notes outline the changes in more detail.

因此,使用正确的样式,或者 jQuery 中的切换函数是正确的选择。

关于javascript - Rails 3.1 是否包括整个 jQuery 库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7538200/

相关文章:

ruby-on-rails - 为什么我不能用重载方法在 define_method 中调用 super?

javascript - 动态重新排列 child 以适应有限空间中的大多数

javascript - Laravel 无法使用模态和 ajax 的增量方法添加数量

ruby-on-rails - 使用 ActiveAdmin 的多步表单?

javascript - 在注释标签中包含 javascript 代码 "<!--//-->"

javascript - 如何在光标下的所有元素上调用 mouseover?

ruby-on-rails - Rails 3.1 中的并行处理? -- 检查断开的链接

javascript - 在 LyX 中语法突出显示 Javascript,插入子项 -> 程序列表

javascript - 使帮助文本显示在 MDC 文本字段下方

javascript - 过滤子文档数组,同时如果为空仍返回父数据