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 Lun <[email protected]>
wrote:
> 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
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to