如何以模态页脚提交数据?

时间:2013-04-10 06:46:16

标签: ruby-on-rails twitter-bootstrap

以下代码未提交评论

.modal{ :id=>"#{digest.policy.id}", :class=>'modal hide'}
  .modal-header
    %h3
      = digest.policy.name
  .modal-body{ :style=>'display: block; height:200px;'}
    .modal-form
      = form_tag '/alerts/archive', :name=>"form#{digest.policy.id}", :remote=>'true' do
        = hidden_field_tag 'policy_id', digest.policy.id
        = hidden_field_tag 'parent_id', id
  .modal-footer
    #div{:style=>'text-align:left;'}Comment:
    = text_area_tag  'comment', '' , :cols=>'85', :rows=>'3'
    %a(data-toggle="modal" href="##{digest.policy.id}" class="btn" class="btn")Cancel
    %a(onclick="javascript:document.form#{digest.policy.id}.submit()" class="btn btn-primary")Archive

2 个答案:

答案 0 :(得分:0)

您的textarea是外部标签。我建议将你的模态包装成表单元素并使用普通的提交按钮。

示例:

= form_tag '/alerts/archive', :name=>"form#{digest.policy.id}", :remote=>'true' do
  .modal{ :id=>"#{digest.policy.id}", :class=>'modal hide'}
    .modal-header
      %h3
        = digest.policy.name
    .modal-body{ :style=>'display: block; height:200px;'}
      .modal-form
        = hidden_field_tag 'policy_id', digest.policy.id
        = hidden_field_tag 'parent_id', id
    .modal-footer
      #div{:style=>'text-align:left;'}Comment:
      = text_area_tag  'comment', '' , :cols=>'85', :rows=>'3'
      %a(data-toggle="modal" href="##{digest.policy.id}" class="btn" class="btn")Cancel
      = submit_tag "Archive", :class => "btn btn-primary"

答案 1 :(得分:0)

成功!

= form_tag '/alerts/archive', :name=>"form#{digest.policy.id}", :remote=>'true' do
  .modal{ :id=>"#{digest.policy.id}", :class=>'modal hide'}
    .modal-header
      %h3
        = digest.policy.name
    .modal-body{ :style=>'display: block; height:200px;'}
      .modal-form
        = hidden_field_tag 'policy_id', digest.policy.id
        = hidden_field_tag 'parent_id', id
    .modal-footer
      #div{:style=>'text-align:left;'}Comment:
      = text_area_tag  'comment', '' , :cols=>'85', :rows=>'3'
      %a(data-toggle="modal" href="##{digest.policy.id}" class="btn" class="btn")Cancel
      %a(onclick="javascript:document.form#{digest.policy.id}.submit()" class="btn btn-primary")Archive