Prototype Event.observe doesn't work in partial

Dear all

I encountered a problem to generate a zebra stripe table. My program is no problem when the page is first load. But after the form_remote_tag submitted, the prototype script could not addClassName to the new table tr element. Any one know what is going wrong??

Furthermore, is it good practice for inline prototype script in _event_list.html.erb?

Thank you very much

Valentino

index.html.erb ... ... <div id="event_list">     <%= render :partial => 'event_list' %> </div>

_event_list.html.erb ... ... code to generate the table ... ... <script type="text/javascript" charset="utf-8">     function stripe() {         var evens = $$('table#event_table tr:nth-child(odd)');         if(evens) {             evens.each(function(tr) {                 tr.addClassName('oddrow');             });         }     }     // document.observe("dom:loaded", stripe)     Event.observe(window, 'load', stripe, true); </script>

event_controller.rb     def index         ...         ...         if request.xml_http_request?             respond_to do |format|                 format.html {render :partial => "event_list"}             end         end     end

I suspect the Event.observe(window, 'load', stripe, true); is not executed after an AJAX call, and you will have to call your stripe() function explicitly.

Cheers, Nicholas