Helper for making FAQ top links

Here's a simple helper for adding top-style links to a long frequently asked questions document.

Add the code below to your helpers/application_helpers.rb file.

def top
  '<a href="#" class="top" onclick="window.scrollTo(0,0);return false;">top</a>'
end

Then add <%= top %> to each FAQ answer:

<h2><a>Does Rails scale?</a><%= top %></h2>

For extra credit, style and tweak the markup to your liking.

May 11, 2007

New comments are disabled right now. Once we finish migrating this blog, we'll restore them.