开发者

HTML (or Rails) button code issue

开发者 https://www.devze.com 2023-01-20 16:13 出处:网络
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

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'>&lt;&lt; Back</button></a>"
end


You might try the "button_to" tag: Rails API

0

精彩评论

暂无评论...
验证码 换一张
取 消