I have some rhtml (see below) which includes 5 divs placed under a div
with classname “container”. Can somone help me write some RJS to
a. Find the “container” div
b. Loop through the 5 child divs and:
i. Change the innerHTML (text of the hyperlink) of each child div
which is a hyperlink using link_to_remote (I assume something similar
to page.replace_html)
ii. Change the “url” of each child div to point to another url
Some sample code would be appreciated. I’m not sure where to start
really.
Thanks!
Chirag
<div class="container">
<div class="selsec">
<%=link_to_remote("Live!",
:update => 'chart',
:url => url_for(:controller =>
‘chart’, :action => ‘live’),
:loading => "Element.show(‘loading’); ",
:complete => “Element.hide(‘loading’)”,
:before => “toggleVTabs(this.parentNode);”) %>
<%=link_to_remote(“Last half hour”,
:update => ‘chart’,
:url => url_for(:controller =>
‘chart’, :action => ‘last_half_hour’),
:loading => "Element.show(‘loading’); ",
:complete => “Element.hide(‘loading’)”,
:before => “toggleVTabs(this.parentNode);”) %>
</
div>
<%=link_to_remote(“Last hour”,
:update => ‘chart’,
:url => url_for(:controller =>
‘chart’, :action => ‘last_hour’),
:loading => "Element.show(‘loading’); ",
:complete => “Element.hide(‘loading’)”,
:before => “toggleVTabs(this.parentNode);”) %>
<%=link_to_remote(“Last 6 hours”,
:update => ‘chart’,
:url => url_for(:controller =>
‘chart’, :action => ‘last_six_hours’),
:loading => "Element.show(‘loading’); ",
:complete => “Element.hide(‘loading’)”,
:before => “toggleVTabs(this.parentNode);”) %>
<%=link_to_remote(“All day”,
:update => ‘chart’,
:url => url_for(:controller =>
‘chart’, :action => ‘all_day’),
:loading => "Element.show(‘loading’); ",
:complete => “Element.hide(‘loading’)”,
:before => “toggleVTabs(this.parentNode);”) %>