observe_field loses event binding after firing

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 %>

The corresponding controller actions:

  def ajax_show_subject_list
    render :update do |page|
      page.show :ajax_subject_list

  def ajax_hide_subject_list
    render :update do |page|
      page.hide :ajax_subject_list

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.

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?




I have just run in to that problem. The difference is that I am using
seemed to solve the problem. Now my :function is properly fired every
time a field change is observed.


Oh, just found this bug entry you may be interested in: