• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

RubyForm

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
end When click submit_tag "Cancel", the paramsi are:
{"button_identifier"=>"", "check_box2"=>"selected", "commit"=>"Cancel", "radio_button"=>"2 was selected", "action"=>"test_action", "controller"=>"index", "text_tag"=>"default_content", "text_area"=>"default_content", "password"=>"", "file"=>"", "select"=>"option2"}
    if params[:commit]  == "Cancel"
render :text => "Clicked on Cancel"
else
render :text => "Clicked on Delete"
end
****************
In form_tag, if you put multiple submit button, like
<%= submit_tag("Update", :name=>"submit"%>
<%= submit_tag("Delete", :name=>"submit"%>
The value of params[:submit] depends on which button you click, either
"Update" or "Delete". However, in form_remote_tag, no matter you click
which button, params[:submit] is always "Update".
Solution to this defect:
<%= hidden_field_tag "button_identifier" %>
<%= submit_tag("Update", :name=>"submit",:onclick=>"$
('button_identifier').value='Update'") %>
<%= submit_tag("Delete", :name=>"submit", :onclick=>"$
('button_identifier').value='Delete') %>
 
给form_tag 指定 class的CSS样式
<% form_tag url_for(:action => "aaa"),:class => "clearfix setsmt" do%>

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
一站式Ruby on Rails-从头开始构建Web应用程序发布时间:2022-07-14
下一篇:
基于ruby的watir自动化测试 笔记二发布时间:2022-07-14
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap