0

私のレールアプリで、ユーザーがボタンをクリックすると、ブラウザはjs投稿要求を送信し、コントローラは何かを計算し、ブラウザにjs SweetAlert2(swal)を返します。rails SweetAlert 2がie11で動作しない

クローム、ファイヤーフォックス、サファリでうまく機能します。しかし、ie11では、ボタンをクリックしても何も起こりません!どんな考え?

ここには、js投稿要求を送信するビュー内のsubmit_tagボタンがあります。ここで

<%= form_tag('check_exemption', remote: true) do %> 
    # Here are some radio buttons that are used to pass parameters to the controller. 

    <p><%= submit_tag('Check Exemption', class: 'btn btn-danger btn-block btn-xl') %></p> 
<% end %> 

は、ルートである:ここでは

post ':action', to: 'protected_assets#check_exemption' 

はprotected_assets_controllerでのアクションである:ここで

def check_exemption 
    # Here the controller calculates some stuff to be returned in the swal below. 

    respond_to do |format| 
    format.html { redirect_to root_url } 
    format.js { render js: "swal('#{@financial_product.product_exemption_text}', '#{@financial_product.twelve_months_exempt_text} #{@financial_product.withdrawals_exemption_text}', '#{@financial_product.swal_type}')" } 
    end 
end 

はIE11は、我々はのSwaIが正しく返されることがわかりパネルを検査です。しかし、スワールは画面に表示されません!ページもそれが必要のような要求ではなく、JSのHTML要求された場合はroot_urlにリダイレクトされていないことに注意してください:

ie 11 panel

私はレールに新しい趣味、ウェブ開発、ジャバスクリプト、HTMLのだけど、あなたの子供や賢い犬に話していたかのようにあなたの答えを書いてください。

答えて

1

私の答えが見つかりました。

rails-assets.orgの「rails-assets-sweetalert2」という宝石を使用しています。手順では、application.jsに//= require sweetalert2を追加するだけでよいことになります。

しかし、宝石「rails-assets-sweetalert2」はIE互換性のための宝石「rails-assets-es6-promise」に依存しているため、//= require es6-promiseも追加する必要があることがわかりました。

すべてが現在正常に機能しています。

関連する問題