I had a dropdown. I need to add a textbox when the value changes in the dropdown. I had done this using "obseve_field" tag in rails 2.3.5. Now I am moving into rails 3. So how I write it in rails 3.
Asked
Active
Viewed 1.1k times
1 Answers
16
If you want to use the legacy Prototype helpers (like observe_field
) in Rails 3, check out the GitHub repository for prototype_legacy_helper
.
Otherwise, you can write this JavaScript yourself using the new UJS. See these two blocks of code for the old observe_field
method:
- http://github.com/rails/prototype_legacy_helper/blob/c91b90/lib/prototype_helper.rb#L359-365
- http://github.com/rails/prototype_legacy_helper/blob/c91b90/lib/prototype_helper.rb#L415-429
and see Part 2 at http://www.simonecarletti.com/blog/2010/06/unobtrusive-javascript-in-rails-3/ to see how to do this in jQuery.

Michelle Tilley
- 157,729
- 40
- 374
- 311
-
what about rails 3.2? got Uncaught ReferenceError: Form is not defined error – vamsi Oct 09 '14 at 09:37