I'm struggling with the following problem: What's the correct HTML (and/or Rails) code for
- a button that resides within a form, and
- that should lead to a new page, but
- should not submit anything (from the form)?
Basically, t开发者_如何学Che button should work exactly like a hyperlink.
Thanks for your help!
Tom
Old question, but for teh Googlez I have a non-JS solution. You can extract the button to a helper method, and then return the html for the button with the link generated by url_for. Use a dummy button as a link and you won't have to worry about doing something fancy to style the button.
def back_button
target_url = url_for :controller => :users, :action => :new
"<a href=#{target_url} style='text-decoration:none;'><button type='button'><< Back</button></a>"
end
You might try the "button_to" tag: Rails API
精彩评论