开发者

Does rails 3.1 include the entire jQuery library?

开发者 https://www.devze.com 2023-04-07 11:17 出处:网络
I have been really p开发者_开发百科uzzled because I was trying to work out some jQuery tutorials in coffeescript for rails 3.1 and it seems like none of the animation functions of jquery work.

I have been really p开发者_开发百科uzzled because I was trying to work out some jQuery tutorials in coffeescript for rails 3.1 and it seems like none of the animation functions of jquery work.

For example, this does nothing:

/assets/javascripts/my_controller.js.coffee:

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

However, if I do this:

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

I do get the correct text. Can anyone tell me what is going on here?

THANK YOU EVERYONE, and thanks Trevor for reading my mind. Thanks Benoit for helping me to properly use the site. My final answer below.


I dug around a bit and found this: (from 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.

So, using the correct style, or the toggle functions in jQuery are the right option.

0

精彩评论

暂无评论...
验证码 换一张
取 消