I'd like my print link to look like a button. Its action responds to
a GET request (as I think it should.) I wrote this helper:
<code>
def button_link( label, path, *features ) # makes a link look like a
button
linktext = "<input type=button value='" << label << "' onClick=\""
if features.length > 0 # opens new window, assigns features
linktext << "window.open('" << path << "','" << label << "'"
features.each { |feature| linktext << ",'" << feature << "'" }
linktext << ');return false;">'
else # opens in same window
linktext << "self.location='" << path << '\'">'
end
end
</code>
Which works as expected in the view, e.g.
<code>
<%= button_link( 'Print', url_for( ... ), 'new_window' ) %>
</code>
But feels kind of hacky. Does anyone have a more elegant solution?
TIA,
Craig
--
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.