在我的Rails应用程序中,当用户单击按钮时,浏览器发送js发布请求,控制器计算一些内容,然后将js SweetAlert2(swal)返回到浏览器。
它在chrome,firefox和safari上效果很好。但是在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检查面板,在该面板中我们可以看到小牛肉已正确归还。但是,屏幕上不显示小号!请注意,如果请求是html请求而不是js,则该页面也不会重定向到root_url:
我是Rails,Web开发,javascript,html,css等的新手。因此,请写出您的答案,就像是在与孩子或智者说话一样。
我找到了答案。
我正在使用来自rails-assets.org的gem'rails-assets-sweetalert2'。说明说,您只需要添加//= require sweetalert2
application.js。
但是,我发现您还需要添加,//= require es6-promise
因为gem'rails-assets-sweetalert2'依赖于gem'rails-assets-es6-promise'来实现IE兼容性。
现在一切正常。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句