loucal
loucal

Reputation: 114

Does rails 3.1 include the entire jQuery library?

I have been really puzzled 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.

Upvotes: 2

Views: 244

Answers (1)

loucal
loucal

Reputation: 114

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.

Upvotes: 1

Related Questions