# Prototype Event.observe doesn't work in partial

**URL:** <https://www.ruby-forum.com/t/prototype-event-observe-doesnt-work-in-partial/171309>\
**Category:** Rails\
**Created:** [June 30, 2009, 12:12pm UTC](https://www.ruby-forum.com/t/prototype-event-observe-doesnt-work-in-partial/171309 "2009-06-30T12:12:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![on9west](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/6f9a4e/32.png) [@on9west](https://www.ruby-forum.com/u/on9west)\
**Post date:** [June 30, 2009, 12:12pm UTC](https://www.ruby-forum.com/t/prototype-event-observe-doesnt-work-in-partial/171309/1 "2009-06-30T12:12:02Z")

</div>

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

 \<%= render :partial =\> 'event\_list' %\>

\_event\_list.html.erb  
…  
… code to generate the table …  
…

event\_controller.rb  
def index  
…  
…  
if request.xml\_http\_request?  
respond\_to do |format|  
format.html {render :partial =\> “event\_list”}  
end  
end  
end

---

<div class="post-metadata">

**Author:** ![on9west](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/6f9a4e/32.png) [@on9west](https://www.ruby-forum.com/u/on9west)\
**Post date:** [June 30, 2009, 4:56pm UTC](https://www.ruby-forum.com/t/prototype-event-observe-doesnt-work-in-partial/171309/2 "2009-06-30T16:56:29Z")

</div>

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

On Jun 30, 6:12 am, Valentino L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
