#45 RJS Tips

This episode is packed with little RJS goodies. Learn the different ways to access an element, how to add "if" conditions and how to apply an effect to multiple elements.
# do_magic.rjs
page[:reviews].toggle

page[:review_name].value = "this is cool"

page << "if ($('review_name').value == 'foo') {"
page.alert('hi foo!')
page << "}"

page.select("#reviews strong").each do |element|
  element.visual_effect :highlight
end

<%= link_to_function "Show me the Magic!" do |page|
  #...
end %>

你可能感兴趣的:(Access)