So you’re using Prototype Helpers in your new Ruby on Rails application…
Just be warned
If you plan on using observe_field with a radio input field (for each field), it’ll only fire the FIRST time you check the radio button.
The reason:
The Form.Element.EventObserver keeps track of a lastValue… and when you have a fresh radio, the lastValue is null… and when you click it, it’s value changes to the radio’s value… which btw, doesn’t change. So the next time you go to select the radio, it’s previous value hasn’t changed.
The fix:
Go old school? register the onClick? I haven’t tried this approach as it’s a Friday and I’m done messing with JavaScript.
Maybe I’m wrong, someone enlighten me?
Quick google search yields this: http://tr.openmonkey.com/articles/2006/03/13/observe_field-and-radio-buttons.
Also, `observe_field` should fire with `:on => click` when watching radio buttons (according to the API) so perhaps your code has a typo?
Actually that’s exactly what I’m doing… I have a separate observer for each radio with the same name and different IDs…
http://wrath.rubyonrails.org/pipermail/rails-spinoffs/2005-November/001276.html
That’s what I was going off of…
And I’m not talking about doing :on => ‘onClick’ ... I’m actually meaning go completely inline with onClick=”function()”