フォームがあり、送信ボタンでフォームを送信してリダイレクトしたいが、同時にモーダルを表示して、それはものですか(約35秒かかります)。どのように提出ボタンを提出してモーダルを呼び出すことができますか?送信ボタンでモーダルをトリガーしてRailsをリダイレクトする方法
<%= form_for @tenant, url: wizard_path, method: :put, validate: true do |f| %>
Blah...Blah...
<div class="actions">
<%= f.submit "Submit Report Information" data-toggle="modal" data-target="#pleaseWaitDialog" %>
<!---Waiting Modal--->
<div class="modal hide" id="pleaseWaitDialog" data-backdrop="static" data-keyboard="false">
<div class="modal-header">
<h1>Processing...<small>May take up to 1 minute</small></h1>
</div>
<div class="modal-body">
<div class="progress progress-striped active">
<div class="bar" style="width: 100%;"></div>
</div>
</div>
</div>
</div>
<% end %>
これは私のコントローラですが(邪悪な宝石)ステップコントローラですが、これはフォームプロセスの最後のステップです。
class Tenants::ReportStepsController < ApplicationController
include Wicked::Wizard
before_filter :authenticate_tenant!
steps :basic_info, :bill_input, :upsell_input, :report_pay, :bank_trans, :confirm_info
def show
@tenant = current_tenant
@tenant.build_bill if @tenant.bill.blank?
...
@tenant.build_upsell if @tenant.upsell.blank?
...
end
@tenant.build_transaction if @tenant.transaction.blank?
render_wizard
end
def update
...
end
private
def finish_wizard_path
@tenant = current_tenant
@tenant.build_report if @tenant.report.blank?
@tenant.build_api_aggregation if @tenant.api_aggregation.blank?
@tenant.api_aggregation.save
@tenant.report.save
GetTransactionsWorker.perform_in(6.minutes, @tenant.id.to_s)
TransAggregationWorker.perform_in(7.minutes, @tenant.id.to_s)
<!---I assume calling the modal in the controller would happen here ---->
tenants_dashboard_path
end
リダイレクトされている場合は、コントローラでそれを実行できます。あなたの関数の成功(処理が完了したとき)がそのページへのリダイレクトをトリガーするような種類のITS IN BACK END。フロントエンドでは、ユーザーに処理を見せるためにjavascriptを追加するだけです。 – 7urkm3n
はい、リダイレクトします。 – SupremeA
コントローラでモーダルを呼び出すにはどうすればいいですか? – SupremeA