I'm running into an odd problem where I'm observing two radio buttons via observe_field to make AJAX calls, and it seems to lose the event binding after the first call.
The basic functionality is that clicking on the "teacher" radio button will show the list of subjects, while clicking on the "student" button will hide these again.
The portions of the rhtml template:
<%= radio_button_tag "user_type", "Student", true %>Student <%= observe_field "user_type_student", :url => { :action => "ajax_hide_subject_list" }, :method => :get %> <%= radio_button_tag "user_type", "Teacher", false %>Teacher <%= observe_field "user_type_teacher", :url => { :action => "ajax_show_subject_list" }, :method => :get %>
<ul id="ajax_subject_list" style="display:none"> <%= render :partial => "subject", :collection => @subjects %> </ul>
The corresponding controller actions:
def ajax_show_subject_list render :update do |page| page.show :ajax_subject_list end end
def ajax_hide_subject_list render :update do |page| page.hide :ajax_subject_list end end
Very simple. The problem I'm seeing is that an AJAX call is fired only on the first click. Subsequent clicks don't do anything. It looks like the binding of the event to the DOM ID is lost somehow during the server update.
Questions: What are good debugging tools to find out what events are associated to a given DOM ID? Is this a Rails bug? Are there workarounds short of going to full custom Javascript?
Thanks,
Wolf