I''ve run into an annoying thing about the Javascript generated by an
RJS
template of mine and I''m not sure how to work around it. I''d
prefer to
avoid writing raw JS if I can. I''m looping through a set of elements
and
removing four different CSS classes, only one of which will be present
for each element but I don''t know which one.
page.select(''#content div.address_box'').each do |elem|
elem.removeClassName ''foreign_outline''
elem.removeClassName ''good_outline''
elem.removeClassName ''normal_outline''
elem.removeClassName ''bad_outline''
end
According to the error I get, the JS produced by this actually chains
all of those removeClassName calls together, because each one is
supposed to return the node from which the class was removed.
$$("#content div.address_box").each(function(value, index){
value.removeClassName("foreign_outline").removeClassName("good_outline")...etc.
If any of the removeClassName calls fails it returns nil and the next
call in the chain throws an error. If there isn''t a way to force these
calls to not be chained then I guess I''ll be doing raw JS. Any ideas?
--
Posted via http://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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---