简体   繁体   English

Bootstrap Rails确认提交表单上的弹出窗口

[英]Bootstrap Rails confirm popup on submit form

I am using Rails 3.2 and Bootstrap 3. 我正在使用Rails 3.2和Bootstrap 3。

I have a form that I would like to have a pop up confirmation for when completed. 我有一个表格,希望填写时能弹出确认信息。 The pop up should list the user's inputs on the form and ask if they are correct or not. 弹出窗口应在表单上列出用户的输入,并询问它们是否正确。 If yes is clicked then the form should be submitted, if no is clicked then the user should be able to edit the form again. 如果单击“是”,则应提交表单;如果单击“否”,则用户应能够再次编辑该表单。

  1. When I add a sample bootstrap popup modal in place of the submit button, the pop up is displayed on click but then submits the form instantly and does not let the user click yes or no. 当我添加示例引导程序弹出窗口模式代替“提交”按钮时,弹出窗口在单击时显示,但随后立即提交表单,并且不允许用户单击“是”或“否”。

     <%= form_for(@family, :url => families_path(@family), :html => { :method => "put" }, action: "create") do |f| %> <%= label_tag :first_name %> <%= ff.text_field :first_name, placeholder: 'First Name'%> <%= label_tag :last_name %> <%= ff.text_field :last_name, placeholder: 'Last Name'%> 

Am I going about this the correct way? 我要用正确的方法吗?

What is the best way to do a Bootstrap confirm pop up? 引导确认弹出的最佳方法是什么?

Bootstrap buttons are given the submit type by default. 引导按钮默认为提交类型。 I needed to specify type="button" to stop it from acting like a submit button. 我需要指定type =“ button”来阻止其充当提交按钮。

<button type="button" class="btn btn-success btn-lg btn-tall btn-circle" data-toggle="modal" data-target="#myModal">Submit</button>

And then I did not specify type=button for the "yes" button in the modal so that the "yes" button would act as the submit. 然后,我没有为模式中的“是”按钮指定type = button,因此“是”按钮将充当提交。

        <button type="button" class="btn btn-success btn-lg btn-tall btn-circle" data-toggle="modal" data-target="#myModal" style="font-size: 30px">Submit</button>

        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
          <div class="modal-dialog">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel"> Confirmation</h4>
              </div>
              <div class="modal-body">
                  Do you confirm?   
              </div>
              <div class="modal-footer" style="border: none">
                <button type="button" class="btn btn-default" data-dismiss="modal">No</button>
                <button class="btn btn-success">Yes</button>
              </div>
            </div>
          </div>
        </div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM