0

내 레일 앱에서 사용자가 버튼을 클릭하면 브라우저가 js 게시물 요청을 보내고 컨트롤러가 몇 가지 사항을 계산 한 다음 브라우저에 js SweetAlert2 (swal)을 반환합니다.rails SweetAlert 2가 ie11에서 작동하지 않습니다.

크롬, 파이어 폭스 및 사파리에서 매우 잘 작동합니다. 하지만 ie11에서는 버튼을 클릭해도 아무런 변화가 없습니다! 왜 그런가?

다음은 js 게시물 요청을 보내는보기의 submit_tag 버튼입니다.

다음
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 

여기 우리가 swal가 제대로 반환되는 것을 볼 경우 IE11 패널을 검사입니다 여기에

<%= 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 %> 

는 경로입니다. 그러나 swal은 화면에 표시되지 않습니다! ,

ie 11 panel

내가 레일, 웹 개발, 자바 스크립트, HTML로 취미 새로운 해요 : 요청이 대신 JS의 HTML 요청이 경우 페이지가 또한해야처럼 root_url로 리디렉션되지 않도록 유의하시기 바랍니다 css 등. 그래서 아이 또는 현명한 개와 이야기하고있는 것처럼 대답을 적어주십시오.

답변

1

내 대답을 찾았습니다.

rails-assets.org의 'rails-assets-sweetalert2'를 사용하고 있습니다. 안내문에서는 application.js에 //= require sweetalert2 만 추가하면됩니다.

그러나 'rails-assets-sweetalert2'는 IE 호환성을 위해 'rails-assets-es6-promise'에 의존하기 때문에 //= require es6-promise도 추가해야합니다.

이제 모든 것이 예상대로 작동합니다.

관련 문제